pax_global_header00006660000000000000000000000064146640663560014532gustar00rootroot0000000000000052 comment=70f3a3267dba5384ac6f263ed2095f0320cbbbfd python-gvm-24.8.0/000077500000000000000000000000001466406635600137355ustar00rootroot00000000000000python-gvm-24.8.0/.github/000077500000000000000000000000001466406635600152755ustar00rootroot00000000000000python-gvm-24.8.0/.github/CODEOWNERS000066400000000000000000000004451466406635600166730ustar00rootroot00000000000000# default reviewers * @greenbone/python-gvm-maintainers # dev ops .github/ @greenbone/devops @greenbone/python-gvm-maintainers pyproject.toml @greenbone/devops @greenbone/python-gvm-maintainers poetry.lock @greenbone/devops @greenbone/python-gvm-maintainers python-gvm-24.8.0/.github/ISSUE_TEMPLATE.md000066400000000000000000000016711466406635600200070ustar00rootroot00000000000000 ### 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-24.8.0/.github/dependabot.yml000066400000000000000000000010061466406635600201220ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: pip directory: "/" schedule: interval: weekly time: "04:00" allow: - dependency-type: direct - dependency-type: indirect commit-message: prefix: "Deps" groups: python-packages: patterns: - "*" - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" commit-message: prefix: "Deps" groups: github-actions: patterns: - "*" python-gvm-24.8.0/.github/workflows/000077500000000000000000000000001466406635600173325ustar00rootroot00000000000000python-gvm-24.8.0/.github/workflows/auto-merge.yml000066400000000000000000000003351466406635600221230ustar00rootroot00000000000000name: Auto-merge squash on: pull_request_target permissions: contents: write pull-requests: write jobs: auto-merge: uses: greenbone/workflows/.github/workflows/auto-merge.yml@main secrets: inherit python-gvm-24.8.0/.github/workflows/ci.yml000066400000000000000000000034651466406635600204600ustar00rootroot00000000000000name: Test and Lint on: push: branches: - main pull_request: jobs: linting: name: Linting strategy: matrix: python-version: - "3.9" - "3.10" - "3.11" - "3.12" uses: greenbone/workflows/.github/workflows/lint-python.yml@main with: lint-packages: gvm tests python-version: ${{ matrix.python-version }} linter: ruff check test: name: Run tests strategy: matrix: python-version: - "3.9" - "3.10" - "3.11" - "3.12" uses: greenbone/workflows/.github/workflows/test-python.yml@main with: python-version: ${{ matrix.python-version }} mypy: name: Check type hints runs-on: "ubuntu-latest" strategy: matrix: python-version: - "3.9" - "3.10" - "3.11" - "3.12" steps: - uses: actions/checkout@v4 - name: Run mypy uses: greenbone/actions/mypy-python@v3 with: python-version: ${{ matrix.python-version }} codecov: name: Upload coverage to codecov.io needs: test runs-on: "ubuntu-latest" steps: - uses: actions/checkout@v4 - name: Calculate and upload coverage to codecov.io uses: greenbone/actions/coverage-python@v3 with: python-version: "3.10" token: ${{ secrets.CODECOV_TOKEN }} build-docs: name: Build the documentation runs-on: "ubuntu-latest" steps: - uses: actions/checkout@v4 - name: Install poetry and dependencies uses: greenbone/actions/poetry@v3 - name: Build docs run: | cd docs poetry run make html versioning: name: Check versioning uses: greenbone/workflows/.github/workflows/check-version.yml@main python-gvm-24.8.0/.github/workflows/codeql.yml000066400000000000000000000013771466406635600213340ustar00rootroot00000000000000name: "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@v4 - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} queries: security-and-quality - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 python-gvm-24.8.0/.github/workflows/conventional-commits.yml000066400000000000000000000004631466406635600242300ustar00rootroot00000000000000name: Conventional Commits on: pull_request_target: permissions: pull-requests: write contents: read jobs: conventional-commits: name: Conventional Commits runs-on: ubuntu-latest steps: - name: Report Conventional Commits uses: greenbone/actions/conventional-commits@v3 python-gvm-24.8.0/.github/workflows/dependency-review.yml000066400000000000000000000003741466406635600234760ustar00rootroot00000000000000name: 'Dependency Review' on: [pull_request] permissions: contents: read pull-requests: write jobs: dependency-review: runs-on: ubuntu-latest steps: - name: 'Dependency Review' uses: greenbone/actions/dependency-review@v3 python-gvm-24.8.0/.github/workflows/deploy-pypi.yml000066400000000000000000000005011466406635600223240ustar00rootroot00000000000000name: Deploy on PyPI on: release: types: [created] jobs: deploy: permissions: id-token: write runs-on: ubuntu-latest environment: name: pypi url: https://pypi.org/project/python-gvm/ steps: - name: Build and publish to PyPI uses: greenbone/actions/pypi-upload@v3 python-gvm-24.8.0/.github/workflows/github-pages.yml000066400000000000000000000010111466406635600224250ustar00rootroot00000000000000name: Deploy docs to GitHub Pages on: # Runs on pushes targeting the default branch push: branches: [main] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write # Allow one concurrent deployment concurrency: group: "pages" cancel-in-progress: true jobs: deploy: uses: greenbone/workflows/.github/workflows/docs-python.yml@main python-gvm-24.8.0/.github/workflows/release-pontos.yml000066400000000000000000000003631466406635600230170ustar00rootroot00000000000000name: Release Python package on: pull_request: types: [closed] workflow_dispatch: jobs: build-and-release: name: Create a new release uses: greenbone/workflows/.github/workflows/release-python.yml@main secrets: inherit python-gvm-24.8.0/.github/workflows/sbom-upload.yml000066400000000000000000000004151466406635600222770ustar00rootroot00000000000000name: SBOM upload on: workflow_dispatch: push: branches: ["main"] jobs: SBOM-upload: runs-on: ubuntu-latest permissions: id-token: write contents: write steps: - name: 'SBOM upload' uses: greenbone/actions/sbom-upload@v3 python-gvm-24.8.0/.gitignore000066400000000000000000000002041466406635600157210ustar00rootroot00000000000000__pycache__ *.pyc *.log .egg *.egg-info dist build _build .idea .vscode htmlcov .coverage .venv .rej .DS_Store # ruff .ruff_cache/ python-gvm-24.8.0/LICENSE000066400000000000000000001045051466406635600147470ustar00rootroot00000000000000 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-24.8.0/README.md000066400000000000000000000111461466406635600152170ustar00rootroot00000000000000![Greenbone Logo](https://www.greenbone.net/wp-content/uploads/gb_new-logo_horizontal_rgb_small.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/) [![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.yml/badge.svg)](https://github.com/greenbone/python-gvm/actions/workflows/ci.yml) The Greenbone Vulnerability Management Python API library (**python-gvm**) is a collection of APIs that help with remote controlling Greenbone Community Edition installations and Greenbone Enterprise Appliances. The library essentially abstracts accessing the communication protocols Greenbone Management Protocol (GMP) and Open Scanner Protocol (OSP). ## Table of Contents - [Documentation](#documentation) - [Installation](#installation) - [Version](#version) - [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://greenbone.github.io/python-gvm/](https://greenbone.github.io/python-gvm/). 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 frequently update this projects to add features and keep them free from bugs. This is why installing `python-gvm` using pip is recommended. > [!IMPORTANT] > To use `python-gvm` with GMP version of 7, 8 or 9 you must use a release version > that is `<21.5`. In the `21.5` release the support of these versions has been > dropped. > [!IMPORTANT] > To use `python-gvm` with GMP version 20.8 or 21.4 you must use a release version > that is `<24.6`. In the `24.6` release the support of these versions has been > dropped. ### Requirements Python 3.9 and later is supported. ### Install using pip 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 Forum](https://forum.greenbone.net/c/building-from-source-under-the-hood/gmp/11). If you found a problem with the software, please [create an issue](https://github.com/greenbone/python-gvm/issues) on GitHub. ## Maintainer This project is maintained by [Greenbone AG](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 ```shell python3 -m pip install --user poetry ``` Afterwards run ```shell 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-2024 [Greenbone AG](https://www.greenbone.net/) Licensed under the [GNU General Public License v3.0 or later](LICENSE). python-gvm-24.8.0/docs/000077500000000000000000000000001466406635600146655ustar00rootroot00000000000000python-gvm-24.8.0/docs/Makefile000066400000000000000000000011421466406635600163230ustar00rootroot00000000000000# 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-24.8.0/docs/_static/000077500000000000000000000000001466406635600163135ustar00rootroot00000000000000python-gvm-24.8.0/docs/_static/custom.css000066400000000000000000000107101466406635600203360ustar00rootroot00000000000000div.document { width: 1200px; } body { font-family: Helvetica, Verdana; } div.body { max-width: 1200px; } h1, h2, h3, h4, h5, h6 { font-weight:500; } div.body h1, div.body h2, div.body h3, div.body h4, div.body h5, div.body h6 { font-family: Helvetica, Verdana; } .sphinx-tabs-tab { color:var(--color-content-foreground); font-family: Helvetica, Verdana; } a { color: var(--color-content-foreground); text-decoration: none; border-bottom: 1px dotted var(--color-content-foreground); } a:hover { color: #11AB51; border-bottom: 1px solid var(--color-content-foreground); } .related-pages a .page-info .title, .bottom-of-page a { color: var(--color-foreground-secondary); text-decoration: none; border-bottom: 1px dotted var(--color-foreground-secondary); } .related-pages a:hover .page-info .title, .bottom-of-page a:hover { text-decoration: none; color: #11AB51; border-bottom: 1px solid var(--color-foreground-secondary); } a.muted-link { border-bottom:0; } a.muted-link:hover { border-bottom:0; color:#11AB51; } a.sidebar-brand, .toctree-l1 > a.reference, .toc-tree a.reference { border-bottom: 0; } .toctree-l1 > a.reference:hover, .toc-tree a.reference:hover { border-bottom: 0; color: #11AB51; } .related-pages a { border-bottom:0; } .related-pages a:hover { border-bottom:0; } .toctree-wrapper .caption-text, .sidebar-tree .caption-text { font-size:2em; font-weight:500; color: var(--color-content-foreground); } .sidebar-brand-text { text-align:left; } .sidebar-search { color:var(--color-content-foreground); } .sidebar-tree .toctree-l1 > .reference { color: var(--color-content-foreground); } .toc-tree li.scroll-current > .reference { color: var(--color-content-foreground); } .toc-tree .reference { color: var(--color-content-foreground); font-size:1.1em; } .toc-title { color: var(--color-content-foreground); font-size:1.2em; } div.admonition { background-color:var(--color-background-secondary); padding: 20px 20px; border-radius: 4px; } .admonition.note > .admonition-title, .admonition.warning > .admonition-title, .admonition.tip > .admonition-title, .admonition.important > .admonition-title, .admonition.hint > .admonition-title { background-color:var(--color-background-secondary); font-family: Helvetica, Verdana; font-weight: bold; font-size:1em; } div.body p.caption { font-size: 240%; margin-bottom: 0px; } div.sphinxsidebar h3 { font-family: Helvetica, Verdana; } div.sphinxsidebar a { border: 0px; } div.sphinxsidebarwrapper p.description { font-size: 15px; } div.sphinxsidebarwrapper h1.logo { font-size: 25px; } div.sphinxsidebarwrapper h1.logo-name { margin-top:50px; } div.sphinxsidebarwrapper p.description { margin-bottom: 50px; } div.sphinxsidebarwrapper img { max-width: 70%; } .highlight-shell-session .go::before { content: ">"; padding-right: 1em; } .highlight pre { border-radius: 6px; font-family: Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace; font-size: 0.9em; line-height: 1.2; padding: 1.25rem 1.5rem; } .code-block-caption { font-size:0.7em; background-color: var(--color-background-secondary); color: var(--color-foreground-primary); } .code-block-caption a { color:var(--color-foreground-primary); } .code-block-caption a:hover { color:#11AB51; } div.edit-this-page > a.muted-link, svg.icon-tabler-shadow, svg.theme-icon-when-dark, svg.theme-icon-when-light { color:var(--color-content-foreground); } div.edit-this-page > a.muted-link:hover, svg.icon.icon-tabler.icon-tabler-copy:hover, svg.icon-tabler-shadow:hover, svg.theme-icon-when-dark:hover, svg.theme-icon-when-light:hover { color:#11AB51; } .highlight { background-color: var(--color-code-background); color:var(--color-code-foreground); } .highlight button.copybtn { background-color:transparent; } .highlight button.copybtn:hover { background-color:transparent; } svg.icon.icon-tabler.icon-tabler-copy { color: var(--color-code-foreground); } .highlight .go { color: var(--color-code-foreground); font-weight: normal; } .highlight .l { color: var(--color-code-foreground); } #contents.toc { background-color: #ffffff; border: none; } .back-to-top { background-color:var(--color-background-secondary); } div.topic { border-radius: 4px; } div.topic a.reference.internal { border: 0px; } div.toctree-wrapper.compound a.reference.internal { border: 0px; } #indices-and-tables a.reference.internal { border: 0px; } .sidebar-logo { max-width: 70%; } python-gvm-24.8.0/docs/_static/greenbone.png000066400000000000000000000575161466406635600210030ustar00rootroot00000000000000PNG  IHDRKD!_ IDATxGu8~fvo{===Iɲ$I;q1:P$ = ա%@h!Lqll&YͲ,Y=n9ofgf}_wݙ3gΜ>gן?_|+|dd/ӯ~6W;s(zUR.h50k,(ʐcD8Cل=wyQ8%MD[kQCRF~d eHDqA'qA$P B$Q˾?y.0 !I|*jtjj&j,B@TR0J<(T7wPVa@FJ0]҅|F>/aqӾ9Ajl'Io:pa1$jNjԘ694Oq"vƅƺw^KR)FD@GlCAaHG'/9;w,3,48F( gD:9WIrE"-}015~s/gt;g-^:%&EHi"KH|&F3s;Da! #r-٥c է53dIxT48 Ѵi1 Lyi g٘|foY`AJ=QM-gQ}St3(v:x6::Dϲ6g,ܸ1Q?==ʇv/;w^a߭w,fsjD•TLx) c$lHA+Q(5Wp3wE8A4L0B̫pF3IX%x̽XlŤ衍aEn)IWs-"s0󹈹;xi`ڍ^{.xcb`pnis2[z.O;wBh@v{?}xX+PuPZojA$t;n '9d+ GoUFr2fØa([v%8 b1Ӳ˴d:o.*a]KLfBewDg}؝acؔmb.!&:cd..(2{t#WHh#Ò~93c M!PG̦[yǟ\*d2{i3Λo^J_@Ԕ80ˠ @I\9-ޱMw=W-E) R k3ٚnVrp;p8KN XjX/1 ].f4<.sD޳Č`6%gxRD4u_J;YX8, ŒiH3LH0DaG |3ʂ!_tϳw ?e1 ʥ c-CsRdJ,T>R9CԷU(8;;An ]P*w/a'󒝏>}qvc˒$YҮ49h7ȖpȝRDN Dr2,A hHhHpUe.sEl`He)j[8j(С;&o՞\Pxͤ=A",{l׆ճ V A{49# 3%͜Оg9ן Ҁ$?F.j9Ta7n`wG7 []0Î5x-c,4$ZfM !װ1uVA˲&y3Q'M~`e IsbLN͢.`}.Igɍ9y Y݌,g"Aq{3g4ǽ+\#1BpxCvh[jC14 {n vA㙯?IBDznEGe9/c=z8-\p<-iA?Sĵ %MJ(1%K' m}*>aXr-43aX>G: $!zF]M1n(T[/̺LŘ!¤r 5gB1fL-f&v,NzQ5m*d ld23P L*v μ߳b5&kKٿxRBB?:/{Y]{.tJ0:cͧ־iptdRylx"qUaRZ\'WǜsXy׃=_ wk TEE$1tttA\JLN^2S"\aN."g/h|0 ?І p1c3kWOݸ[L%$I/\\- cExg?I ۟(Kq$d]f ̟‹ u1R.# I l,DVڽkRKX3<ܭҝ<>Vu D %UdyH|3 ]#&=\ڵ#jZ A!Zi#R*&fRҸ0[f g'#h_.RssyV ʕmKɹH3hd+336bY֣4" d/gh`Ngdm]U^IphfFp[+rP2R3 5rrr!Y }U`0x:߭aW=qY_2/reQ+Q]T+p!v=d҉2F5YGQe;s3'hMŀtCGe+W3W"_t {p41'ǝ\EDϙoK Ca,`"Kj-FoRF%?Zv~^qHL&ٔeyRY޳Ve'FzC$,Z$I~  EjJLR3+\)n\q]sFI Ԙj}2W-9@CF;Lˡ3_s^F1K9*imtIYD<涉FK,C `'u?="מy|+l~x s稉H3 F[Gj9oGtR5͛Asv!a(P;ttt.xgqpLƼ͓bn!צ̻hzȊUQxCiGHeOXGzϵ^ ݈SQUBr*1g-J\G6fx+G&wp2ǯB&3wΜ9g3W k֞vr篂qJ$a,iTaսC_?{}ɋ.cOߴ G*?LAP9@Jʼnqx/U:t: Y%b9룇lX_l+wtuZD$ci/VҴobb/4_@GGldF]J\A: c$x ;]'^7dBʖi"=j*h:`u̇|˱Lб256,ep?)PpPqAlc>Jێ_ɚq`-)u IDAT ©H,8oV2Dخ]gTVoo?udãbڇ'`(F-(EC*!rW}&l0q5-g{g.QE t RuY[JDt_Ŀ|KHt1 }Ⱦ3-6;–mS8/سrr|b@*d2kVnB%H=ΞSC- 5 y;X{#p)[|M*)O7?ʒR-Q &/mܽG;?^u|%q@:baXUE {qBLWf ;D  / 7E"\xv\N^d0˜ Qa i 9'3!ǿV+K2\'Zxyc@KGR@X"cM!v8< ipcLDx$IYKLDB$c&|06{ۑz^ogm.^9?NZR㜏 !1Oe&ĚX&@q2e\`!1C <>$NcK8(.PL1;RXI43U$Bw:d X ,])88"\IZKK ˵ (4!`B&#KlQ/u< u@x_}/\+6 A?D]kCX;ӡ,b0Ԥ-%}l}u]=$yKJQ* & 8"r1H$8$.N=:{V݄xB";8V^/i'Hȉ6(axٶ~ppL4oo7k'8c%D\fE$ aXz `ӈ:H-!X+lBWMd"-E<(UYfD1>2l!3]@LSa"{3|4twuCR; tm0xcl J"#)h4)q^xuAe G9~7dD[ IGUc9R==:nd-3m (p\)݊')<v#f҅zgJ9e4rf}^HmAFYp5/'zVJ#qvYfuMj id1UK i;!U`]_k&I/ "n*Zh# <`ѠOwpٚ%oauC!:*ʯ,8ciU ~9Ԯı f0`)\M/U(_a266sO͛7mo\wbwɤ\DSr/oǛo}gbcpυê ^4b/B>'nzYJ#'312O?[>wZcwp#h  ] Oέ9Cs(b01(`@E>zv'56hdWZ_F~ 8 :HDo+vɼ9-n< Z@ PU&dļF .7(m۸E˞s|JMoKY{(pI[n-TN%ejGо U1.M2[Bx}uIr̚|93a].L^¦LqҗzǀX:AZPJ:#S~`!7W{w+m?9ZLK c"*?%! (F0w@I|e}Kg['m&7f4,MlUNSx=cl"w\twwgxϬ A`DgﱴdH)Œ <6[Z\zlB_ !HG("Jt0KT*U?1T[52`=G^N0 22j7Lۍ9>.nTOd10Sٺk2WnƘܕFyT .N)쓫*'>$y_% JP\0a9+ RH]~A4?0 tL*'O3O/1a^QN-!Lr!jUT53^XM2A+>XT>!@ZOfXB׋:V&H2H|UlZȅ(Sʥ?#I't?as2݌6a1 Dx;n)AlLc4)I3YW(W؝x&-C")\ tvu Q~RkT.0ɂd3j[ 8ݽ#洤+@rzt"P"4޿MP1F! "PI:Ӛ ˚2rScVC;4Yj6ox,Q6+Vɒ[k3$wgגګ%N9wG#>5:g.}{@J?2[JΙ3K#@5XK/6 R1sF]bkD~OO`u+tQ&Z8()ݳg}"-Vl$r{Bi˩_@*hdNld d.\lZB(+d0/_Ǣ:YM8CmZ0na ,is#)Es ٖJ;K\z\V@5 &3%Q*::7]#S7*jWbP^.m `Udzzz @'5*%]QXدNUOYR! t)!XP F]%LJ8"zYt8]| 0$&javajEC޿߽SZuVXo{Ң䖽+* 2Q<HGC~LEf԰T΢Ff}?.[nSMs"XOțc/ Sm$L $tzr ξvB杜I&^e]/E:CaxG 9Nzd~+Bm@h'4Mҡpλe!3K3;@ש h/Z$dY+ٴY7GC"tS`?SwpD\gt|jehs2ɩLr$<;k.t-d ~790OfZW uYZkM0vrL^ޥCF,Q\ i:c0 Y > 3'>vZ˧;z:K_vNsǕ4ž7}3˽ɐ+4 3)c&ϟALmV/FU2oD'vc;!.2/㜯~dZ@F]32(Ɍe?S33d +<̇g 8^)J0Q䛖zFVh #nma-O甉7e0 .#V#c^dD@C0N_4aV'F Դ_cѴ0N}D+D30rΛH%2N PYm\2ZVie! s`HeGtb+)Ig!tfF|J\)TwxSN/㗺WAh lG[diI>>rA!b?c"VO)MP_9 3HE.C{m}0? 8[VH1eQS:b 3GP|T/T)xg!ޔF3N $$L9)Yj$3MSັLrY0¤H T*p8{X..W?p2I1== uHSw5>9JY1L+qLVf+o.d:rW7ajt&JUs }>tnqX|HIIm2j یչ>a|ջhBV.P`kժ=HF:ߓ0zŌ13)cIIcaDcjژ^WȔr)4QT(ȍv|ًdm:fVˌeugf7%97^TN"պUPg̚5!ʭ[ӲKNemN`/R_WFn4%T#k&ԇvJbym]Ҵ5"^:j}E}g,- A 9Q&Өٯr ސXu5,SJ)p_Y011>x0W”˕"y+"&d b<<Ąo>SMF5Yn1[%\s*kd5ԡswaԾg*a;Ƙ6wC9HtvL cl40W8@G!z؅ 'y>| !(]'qs^.oLZj3K:L] }? X0 7JI RXuIv֚ j[8dke]st05 LC0ڲZMиdL4dĄ恁'0}X1YqH%ګjjsŭVG# ;~BoW%C/?NTy'&?Id; E #Ibp̀b^k'^`f1Gc[wHBċ.xŋ;F+7Ǝv㔩o AyX&Z2ӴiZ=䤋Ik^°ݻwO l5#텎ZMGAih׻<) M6p@|?q5C"""d!@u~T0g%CC!k:e\16$Pj}<`MGz} 8BfS:QUYl4D*}Ф`R@sq֒ Z^'E譭Vk4?AxGdgݻo'!tե6zp\0U*Z)Ab:Z*XN{&!%XWw|>A[f2v@q&pVKfaqAԆC~dU..A?#IDATBoz\ϥv$8 v0\ݍbpio ǷǞPJN_gw;z^#;Z(|6,`޽g߾⇼_%q,S9^9I\z0w3P킝cPvT5#1Kf s!̎%Iq,9dsEja*$ɰ1VKb6CFTq'/ℽfwt#RMdOMNNq|||SJٸVF"j,O<&Lr̭cxaSy; vbJ?e^mP)q, ]TE]a*E2p Ju 9y}bO4h_ǿ?,p#a$(zRi5l%KFaִkUkuh5,LTּoO񮿹N2WkI-_dIyqdC+#mzR'9-RL?sgoZN{JE?L' ˋ{('$9V ~38QU| DĵG_Ӧi֕8Gd`YӘXd#pRJL-btk^DU`i<c#c#񎎎s8{nŚuztKf%+dƷ*'Z̞,/4!Y%UG͞'AgӖxO86Jd^dym)P!]6 !na}@vѣȧI-"o˝GKjarB$c?B|8՝+=DRm403Њ 0Q `]+ !eaq`H\$4_hN7|EpJذw0L$a No$bZܡI%邚c0j=LNpĊOnSN>KZը$/+KG~IJR ,n7Wa$k* ;Q%u.T4x;bP- sOL3dZU#@I `a5[MYL< )>aȅn5%MrŊ$ɔ~ed UdPuqːfq*Oy۹sg!̅Tė]_4Z{؆h~*'FǠhx7++0~$kS 2Lb4t4Ap{y ؘ\~F%6֎H… nR5WL˖KݚZCv^wZo;vr ==(Su.I1`~S˔(%܅!7aLw8I҂݌f ~!Kl2Ն9j^a?iŀ(TDMJC+vp+q@ΆrCH/sa0[2&EI*rާѴ& l@!684e݁=zEW!MyڇF^r0Iwr Ucwr?/c]H1QCgxL!"8xb?ޫ*`^:uŗ_?~=DΞmw}W"I`j˒<澆XsA X}ffhsD>9#ιm ]5uk$a,' P#op_z{%K fׯ~i׷ܮ)ՇJjؐ4L]mOZT6 ֓"9Dg|zqHY%,e4(]b ch$ӾPj\n8bX3{9ו̀,JFa2\mYgOΝi{FV1Ct|RCc..B@k؀U\ƅ: FP{<>0&W{B©6eѤ62N*OTpz{pwMOwj2S0fC:M{ԻeaŧW̓jE֗4R-UtMES00g"iKAhdyDNOAΜMA+MG, '84s0d6.Hn2NI7 BvǴs7aLspm 3-cCנ35@\O#/z,K?{~0X!&Ѧ$f EDօLfqY9~2Fs+/S{TYT#}CI.XCKxE{ ajM _~eDѝ;+WeS'&F2/]9/}zUOV㓻9MX7mڱϻFڞniFל?bYXL9@3$q < }mu:ks2Fvy:K7y=0U6YX]8#8 bmR;āЂHLo›#ջ:0V?iN<7)T]-tCc3%ɂfR fpݼܶ~G{frۇ(j `M])2 €ͩɔ{We@[DPiy]M$u2=z]{&_9睛>55~˯?O񏃨}ttGg}+|?o|;7*_:]PC(LDuc?Ѝz[sy$/564͙RWs4ZCޞ-># ̾ڶR< IAf>WwQt,3)ӫ)+=ve YBL5\5 bFL5Q*M+%Ӏ=eFUd~s8W$(-k=(WQӪ8FG}y{s=+_pٍ5V%7accĄ\Ko}+ө-/9E9.=wQ^6s 7WO6~x4ŇGɫ+YAA3a?;m-G䝟1 (ms3|U..7:y #R#Y!p=Crh f$BnA}6 uRt?B mˆ:3CY j\v(sh2js% N0<7 b~:{TyM=Ge='|䶇;N$NBR#"#}g!ӝV ::EZF*!~Oͯ'6<=? JVvؔǤC-V]I[E*0HϜsN9G:W7[$/ 22uK 1|7ҧ2 f\HABȡ Pg@lئA酪(`N͇) t.Y{&kΛvMk'@5& T% wl]}{ _JE]4}ѥVg`0x%q@SUUfGii`t-[۾X@sNV}_tnDv%>tXG=#c(bo"ɠIsĬrl,HyEZ*\ XƋ`)͵Sj]=m]jpQʹ94m磍 r)U ԠIG{D-yKS@{&By7F?W۠7k:{;cctBf͝(5==˯E34ke_ƿ15`h  Ic7%z'ѣ[.Oq{3Ӣ>Tm"3cNӐ6ZU$X; 5 }h&uʀƼZbkͰ֙й(9t”t$ oѐ]dk͓twѧv{0 L&ѓ8y8p(1Mn7GŽs8rj=i!r-[qًx?~#W5PkVwqG?7m_{WG!ke"%-6h(Ra$ DCB*$DE@> gH;dwv̼l *{o{sp㣗 {g҆qFI˓s~?ڀ䅳;BĭNT28}<̞~Fv^kΘE@hҫZ\fJe:`SYl $-ZP 7k-`Ji;-)DczxR#<0g9KpX~εrP)<4Hƹ4dFyl!mGWg^{kZ v*[EŸ8/nooKo~vA 4w§oLE44˭bj؏bjڦX~ۆ&$KK_Yde)DzyHLNF+trxɰ$N_IH N1#=B|$TŜ\s>g5 0wkd~F%0Q._ Gw|U&Q _zwp$Bʺ66rT%=WEmqxIKݻ-6]j|?GNnlP$\q(|GpV4PgJ'vUTSU'e\i$Hj$cPs\r&rnicuvTVoM=OVu]QJAbf'=9=B2x>a(p'ޫ|sY+? Ϗ[o ?Ϧo"Y\(Y4FzHB8s:rezжwBʙ@i8pώQ!^i"eP9nU6 ,j̯*f#`dvFG8'R$I+Gh-IH1zZ0 '4h'J<@GBdasi+πeraǻG>w"Ltʀ"Hf 46'bvۭB(uQr<:n2߀NW&:J#6QS.z:{*jԳ'F@11CV B' &DŽѾ@kɣI>sMKmC4jF}sۖJF.*3ePҜnP)DHR_ȗBo&r y6ɬn jkqB!Fá^"ve!yW?%.>F:d!&8?+ZZ$? ͈B+L K ڳݸ6@gj3 ňL̑[Kx񻨹 CE%|l3 !Tyy@39NOK*uuafu֠e8Q"%xw<`%+)r!>$RJl~qy8椝v#dQIGrIENDB`python-gvm-24.8.0/docs/_static/logo.svg000066400000000000000000000507151466406635600200040ustar00rootroot00000000000000 python-gvm-24.8.0/docs/api/000077500000000000000000000000001466406635600154365ustar00rootroot00000000000000python-gvm-24.8.0/docs/api/api.rst000066400000000000000000000007311466406635600167420ustar00rootroot00000000000000.. _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-24.8.0/docs/api/connections.rst000066400000000000000000000004531466406635600205140ustar00rootroot00000000000000.. _connections: Connections ----------- .. automodule:: gvm.connections .. autoclass:: GvmConnection :members: .. autoclass:: SSHConnection :members: .. autoclass:: TLSConnection :members: .. autoclass:: UnixSocketConnection :members: .. autoclass:: DebugConnection :members: python-gvm-24.8.0/docs/api/errors.rst000066400000000000000000000001051466406635600175000ustar00rootroot00000000000000.. _errors: Errors ====== .. automodule:: gvm.errors :members: python-gvm-24.8.0/docs/api/gmp.rst000066400000000000000000000002171466406635600167530ustar00rootroot00000000000000.. _gmp: GMP ^^^ .. automodule:: gvm.protocols.gmp .. autoclass:: GMP :members: .. toctree:: :maxdepth: 1 gmpv224 gmpv225 python-gvm-24.8.0/docs/api/gmpv224.rst000066400000000000000000000037321466406635600173760ustar00rootroot00000000000000.. _gmpv224: GMP v22.4 ^^^^^^^^^ .. automodule:: gvm.protocols.gmp._gmp224 Protocol -------- .. autoclass:: gvm.protocols.gmp.GMPv224 :members: :inherited-members: Enums ----- .. autoclass:: gvm.protocols.gmp.requests.v224.AlertCondition :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.AlertEvent :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.AlertMethod :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.AliveTest :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.CredentialFormat :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.CredentialType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.EntityType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.FeedType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.FilterType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.HostsOrdering :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.HelpFormat :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.InfoType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.PermissionSubjectType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.PortRangeType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.ReportFormatType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.ScannerType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.SnmpAuthAlgorithm :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.SnmpPrivacyAlgorithm :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v224.TicketStatus :members: :undoc-members: python-gvm-24.8.0/docs/api/gmpv225.rst000066400000000000000000000045251466406635600174000ustar00rootroot00000000000000.. _gmpv225: GMP v22.5 ^^^^^^^^^ .. automodule:: gvm.protocols.gmp._gmp225 Protocol -------- .. autoclass:: gvm.protocols.gmp.GMPv225 :members: :inherited-members: Enums ----- .. autoclass:: gvm.protocols.gmp.requests.v225.AlertCondition :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.AlertEvent :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.AlertMethod :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.AliveTest :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.CredentialFormat :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.CredentialType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.EntityType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.FeedType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.FilterType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.HostsOrdering :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.HelpFormat :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.InfoType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.PermissionSubjectType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.PortRangeType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.ReportFormatType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.ResourceType :members: :undoc-members: .. autoclass:: gvm.protocols.gmp.requests.v225.ScannerType :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.SnmpAuthAlgorithm :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.SnmpPrivacyAlgorithm :members: :undoc-members: :no-index: .. autoclass:: gvm.protocols.gmp.requests.v225.TicketStatus :members: :undoc-members: :no-index: python-gvm-24.8.0/docs/api/main.rst000066400000000000000000000001441466406635600171130ustar00rootroot00000000000000.. _main: Main ==== .. automodule:: gvm .. autodata:: __version__ .. autofunction:: get_version python-gvm-24.8.0/docs/api/ospv1.rst000066400000000000000000000001711466406635600172370ustar00rootroot00000000000000.. _ospv1: OSP v1 ^^^^^^ .. automodule:: gvm.protocols.ospv1 .. autoclass:: Osp :members: :inherited-members: python-gvm-24.8.0/docs/api/other.rst000066400000000000000000000001451466406635600173110ustar00rootroot00000000000000Utils ----- .. automodule:: gvm.utils :members: XML --- .. automodule:: gvm.xml :members: python-gvm-24.8.0/docs/api/protocols.rst000066400000000000000000000006111466406635600202120ustar00rootroot00000000000000.. _protocols: Protocols --------- .. automodule:: gvm.protocols .. toctree:: :maxdepth: 1 gmp 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-24.8.0/docs/api/transforms.rst000066400000000000000000000001251466406635600203640ustar00rootroot00000000000000.. _transforms: Transforms ========== .. automodule:: gvm.transforms :members: python-gvm-24.8.0/docs/conf.py000066400000000000000000000157301466406635600161720ustar00rootroot00000000000000# -*- 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 from datetime import datetime sys.path.insert(0, os.path.abspath("..")) import gvm # noqa: E402 # -- Project information ----------------------------------------------------- year = datetime.now().year project = "python-gvm" copyright = f"2018 - {year}, Greenbone AG" author = "Greenbone AG" # 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", ] # 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 = "en" # 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", "dist", ".venv"] # -- 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 = "furo" html_title = project html_favicon = "favicon.png" html_css_files = ["custom.css"] html_logo = "_static/logo.svg" html_static_path = ["_static"] repo_url = "https://github.com/greenbone/python-gvm/" html_theme_options = { "source_repository": repo_url, "source_branch": "main", "source_directory": "src/", "light_css_variables": { "color-content-foreground": "#4C4C4C", "color-foreground-primary": "4C4C4C", "color-foreground-secondary": "#7F7F7F", "color-code-background": "#333333", "color-code-foreground": "#E5E5E5", "color-admonition-title--note": "#11AB51", "admonition-font-size": "0.9rem", "color-background-primary": "#FFFFFF", "color-background-secondary": "#F3F3F3", "color-sidebar-background": "#F3F3F3", }, "dark_css_variables": { "color-content-foreground": "#F3F3F3", "color-foreground-primary": "F3F3F3", "color-foreground-secondary": "#E5E5E5", "color-code-background": "#333333", "color-code-foreground": "#E5E5E5", "color-admonition-title--note": "#11AB51", "admonition-font-size": "0.9rem", "color-background-primary": "#171717", "color-background-secondary": "#4C4C4C", "color-sidebar-background": "#333333", }, "footer_icons": [ { "name": "GitHub", "url": repo_url, "html": """ """, "class": "", }, ], } autodoc_typehints = "description" autodoc_typehints_description_target = "documented" autodoc_class_signature = "separated" add_module_names = False pygments_style = "zenburn" # -- 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 AG", "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-24.8.0/docs/favicon.png000066400000000000000000000501421466406635600170220ustar00rootroot00000000000000PNG  IHDR szzgAMA a IiCCPsRGB IEC61966-2.1HSwX>eVBl"#Ya@Ņ VHUĂ H(gAZU\8ܧ}zy&j9R<:OHɽH gyx~t?op.$P&W " R.TSd ly|B" I>ةآ(G$@`UR,@".Y2GvX@`B, 8C L0ҿ_pH˕͗K3w!lBa)f "#HL 8?flŢko">!N_puk[Vh]3 Z zy8@P< %b0>3o~@zq@qanvRB1n#Dž)4\,XP"MyRD!ɕ2 w ONl~Xv@~- g42y@+͗\LD*A aD@ $<B AT:18 \p` Aa!:b""aH4 Q"rBj]H#-r9\@ 2G1Qu@Ơst4]k=Kut}c1fa\E`X&cX5V5cX7va$^lGXLXC%#W 1'"O%zxb:XF&!!%^'_H$ɒN !%2I IkHH-S>iL&m O:ňL $RJ5e?2BQͩ:ZImvP/S4u%͛Cˤ-Кigih/t ݃EЗkw Hb(k{/LӗT02goUX**|:V~TUsU?y TU^V}FUP թU6RwRPQ__c FHTc!2eXBrV,kMb[Lvv/{LSCsfffqƱ9ٜJ! {--?-jf~7zھbrup@,:m:u 6Qu>cy Gm7046l18c̐ckihhI'&g5x>fob4ekVyVV׬I\,mWlPW :˶vm))Sn1 9a%m;t;|rtuvlp4éĩWggs5KvSmnz˕ҵܭm=}M.]=AXq㝧/^v^Y^O&0m[{`:>=e>>z"=#~~~;yN`k5/ >B Yroc3g,Z0&L~oL̶Gli})*2.QStqt,֬Yg񏩌;jrvgjlRlc웸xEt$ =sl3Ttcܢ˞w|/-G8 cHRMz&u0`:pQ< pHYs   IDATXVkpU<y' I"X*EX2B:*"mu:bE Tl֪:T`QV HHL uonn=gGx)ÚYsk}[k{QQQl\MDwTpIH \6tD"}"Aٙ3+Lf9 e Wcsm* 8~Z2R@S,]׽`B1 X :;c?@GEMD)",C2uEԫ_p(C!% (a" 0ڀ1!sOΩBmI `\ ݦg;z)?S%!r  m @R-V9\Q4T2B"e>F6d.5Q73_QF? `2`f [0זQ[n UCD,B0(𐒅k gpVhg0\:9c꫈&P6Y)2I q 22>z)u] 2 >>zĄXYYT@A bY6&ZŞ+) PGH]4?;oIlH,,(=]fO{54~õܪBD\n|W"i~y8#Y(ˆ E9KGHZ7e&Ljʚ^)FK;3DVsJ/FdW2N8XDp0>L@,g~΁?n35H4 I$kPf_)H*bH:$!0 <ɦ TxepS#c EQxp|דR8 T%љ,LCriy$g1&3/ (ac<of8>[.u~kGqoB!8E;%OQ)Q=plkT`n'77u!z^KhFc8 85_J:+ӒOxNCX Nz;dzBFv.H[TV%5TJJ6۫: 7<_>甈a-B[e?B)'YКLF⊧xOp=Ƥa2#Zк1 >6%4})V`+ݞex iz_Ay(5S[;eQ?_K]ɧqo/zfz"RI_ -ogG$xϛt:jⷩ3Ru _J -Ԯ2'46aI>DdB܉q؀cl]x$R#B{0o NS\ۼVguNܹDۏJ)0c"=ܮe'uUz9 URQ`ZU 5dG!nq>;dA/8,Yn{7ͨU91v nן-R&tFx^)Tvj_l퇬Ryv`B`R2攢.3A;/_m[HL흰 9 'B(s .'ٴʕ < ޒ $k@C[)k%-f% j-+'aԦ)EXh 7Q"F4$!'Gq,}TImZW/ML]T6*mXgscj5 :D`q# 0E0Zl-&A nԡiV7o"8uX/A`-VqQ;S)KNayd"=C^$~{8QS*3mӋr*iY\*Ъ75x7ͫ9Rn]lG7#KJ:Ъ[TwdBvy6=qST؀yߡÄ́X#@&i`c(ptsI8/%lŻϓE/Qķ;Wm#@;ha<9Yfop5gBz}m~^Óh" |h\WM+$r27mp\8U^[iSRREhK3*|u;,Bf iMIzYxFt^ o9Ix#b{-y;q74{y(]o ektG%UjU̜PhIK`ϦpղgKkmq3-MGh_n+BhYG1nΦF՚^2 HU.e/3]҉Q{XI市v?O}|33Iu0B,:ͺTͭo i %=b yVZ!% _Y݊\Q&(~e.t=.ҍA)17ZfUM % %k:y B2A鼮e1-Nso[(Qg $2Et3`@M>[ikN0U_ZвY309OågfwsR7̾Tz|>s1k"qGa` OB ![La-.ȳ2uZ-sxm͋eZ"V-AdH U/-Zhw[% c [۲Ttb*uǛ,ٓ8 M-Y=a YJ<CR;Y ;q'r-dэ/ƸȠ[5JPk5c< C_IZXۀeh'?cE>_wo1*n^narCR9wQC:8 &"*`K!2JLCWAyTߒOlET%SY#YZ{>w5OzSiwb-#a?uZ? ,wWeSB+.ҺW1[d3MYXe凜INo NʙYz#^.=gT?5aW0:0 , FE۫0Ζq3gFcBnrҜs>X{Q;*A4qY|pZ1NȞm.u?vARk0k!#LujyX ]0mmZ1fL@3Sե)\6qe7"V !uq:h!G?3r'B[0ؚVʖ91$IMNҤ)*53B=F ȂvLjɞ?lf~skZBYi&Չdl ɘC|sIMHjͰִmj oL0XC&kn!"ݴ8z<5)/7. Rn^ya@7e""Bi|=BO04., JÇ:?@h" Zо{3zc:u,o!2aق߿:9-*8ԸOI"H#NZ%" d@ț^'!؞"tvm~vP:K􂸐M>ꭱp[dh|&XnW&ă^u3)q |Pz$bWM.."vddp h)O˷Lxj_UDMt]6q~~ 6GjMB1V] '7ϵ& B^-sv11[-)c?N4I@aO| ZKoh\_Hl֋6 G#+ ^vb))p2jr "](S~5_527nz& @ :[|éuZJmr9۶dZf[5ITE:qT@<=Β%(lM 7eɧ|އxάZHk i@-rVڇF:*͊g&D 5_K2ZF8LŪFI2%%4HyLk[j5E8::J̄\.O7lvU,QeH< :O684ȩ-"KzH?WcT3NvJIJYh ,nQ\3JhSvH$Dc8؟ds襋8D&[p| _;56538d X]+jr؈dvN)8H: J{xxR 73pdRPB EHmb-y-ƢT+{!sqPUBBFv:Wm['Pjz;#Y !XK;$n\rPꇕiM![w;s K ~ 89zE[ro'1sR{~P!]ܨFn]QGh"Y2+TxȈd,@nn[UZZ!e6Ehk~,NhUZQ;2= #(\BօǭV۞;_2Zw d Jp:b4ɢnBsK q&B8s ;‘# oX$n'NֲrÁLkwD#`~1-wkt ͠NFVu4TjpvI2FxA{}z:ΈoWdifXS% f5ɛfJ 9/RJ3J|5RpMj%$o5oW60^;tǛ9[ 7LC3&7ʻg8Z| ,mZc [T$EZC Q76b@@&ki-4I _JhoVUcUg7$Oڨў%0$qug2Y#@R(İ5:TVmPvKpp-P(VG%gWG<17c S 7f4x;YfCMڞzCy|HM y[jB]WN|%Hg1FPפOyk?j[*+}TxkL$$oͧXdr-Nhuug%5R ?Li܋GVp ]6=vG}\r\6+Hr>Of}P;pJ7lꡔsl)kɁCsW"49u}I)7& 'Jf>ϵ!ϗܾV)zbJ 5w7W6M|bf 7ҕAdΡZh;ڨk~S=WCBh/_~#pCLܿ\|||1T"N|٣>!Q.EK܀.au0 =Z`ڴiӶu --={qkN\RdڣDPR7hFw@ -0 {]!<gL⡛EIGwU-S@ ZMXXkv6wʬy 8iUg#` KlgKԒT:z=\70Λ 랗AU:Z ;yѣGmu欴AŀДM pNq>oz]Mkdma]sQn@oH46C˪V}\=NhN̙3sۡcOMMM2E#==8zGn}ߌ2Z(qUmԬ  V6$ƖVB7gW_]onZHHH|7kRk9D6 1eXZ5I!; wwZP>zJ ^7٥W"HI>HE±E.9LOO_8ms !swrr ?Z" I]l3OqoF ;n i!Zˮfd"M$ ئKr͵ w뙃NG>Zk)gr3())!)(voyR#Y ܲn'ui[ֱϱ?.ꐄ,x+ig2G.Zvy=T8#Q%KCV2?A0MByS33)d0.rB"aU*sA{5eAi=GB m۩pӲY0+y iO6UZ3y*LJ}̝xTGz Yj}H;??+" gΝ Uֶ5KMևs RVZZaC.w~dRD7|t[ǏShɅ<8E&C-]t{%#e#e$Ebjg8T8"#Y&AsjZ3^٤次d)0 |{߾}w1@5x{JMyWź5vdqe?%K2KTyߐ,B y=IZE%oȐԼ׌0=0;Fԧ֓|H,C~EEE[Gk-Px dx^=C+͗E# W+g䪜ԧ ?fZgzڵ됕'Y? bʮa|l$%H?VD"ߦˆn'xK.Ȇwުt5A>>4}W%eÆ @8+JD%,EhlV}ƭ)Eo=FȀӦRI!i~I2g }/BW|, `~/w-EhP˖鬒NjVZ.}:29z4Ez;_"#]#[]{`mTjrMu!][omUs q]xYI\B iѾ[ B(1≔S}C[+K-܅U$cc}ٸ<SJ:7, ۷ *~h2f2-9rQneJqFTdok}eOV( 2dbx6)g!ۻxٲe,6b&˦~W^yy:̊0 |!z>G roͨz$4K^;( w5'Ff>|,7H.]twÜϓ~XX|˗/밂vR(le/+}!HEYI,u*]W,Edhe[A0%w좹 Zi)oy`v @* ōH}94ƶB8P䒋ddv# }E,++4oKE1#ls1 .dUml Qh )xATB[S!)zl+H[(ԁu-PJqDbիW8$P6.B4S}vuHQF$)Aj>x#.48VSxCOȬ`޽$WaNӏ? OMG9iDCh{xޟ{X֊JZ#S~ɪDf & ųw͚5`쁙,ѾP4{\|3Ƞjԩ; w)ȕQcLmOY" '<,W3l#IKGQ}^1uOP6ÇϿ!PcFd^^at̙}LY وyK2JZbQAjYkZypjn7?NxT؟Fm*Z-?u>qwT"+:He=nU3Z T IBLx޳* n&≫ -6" 3t%J*Ϣ[0m3y^޾}N|~jM!2x^{m[ZB9;utuҌr<NB‡o=#H #3?[aԪO@"k1R5n޼ysɀ -[xw1cwkAM6%u V{o/K,R684OLX:1j'YEilF2k$x߿% c2Kջ5#.\A0Thxx8syV}EvYe3 `<c8k_IUrn`{̝fĤvŨQF2;+2#zgׇ ghq|@6Q=w/*yk4_\'xf*].RSv ܳgkͯwܹs u-Q_.H>#ڳ^AMQ 23El?rmu;^1(f:-Fʳdugw@ٖ ӯ)O`Sngd9 qe|(ANswܹsɁpD@UNNz+k ŋ@W/wM˟ sB ;w64cڥVKMWT/LJJ:lj&رcO A)Nĥ/?u @L^NL,T> sJ0B }jj\)$[zN(!M1*yvOPI O1؞aYvӢV<$6oջM=$CGĤL+(IsDw2x'<6b{pwVf yc\OÇoSxx뭷vמHS\< ΰx֎fd2ihT]eJ^O @@P,ɠl|)EOR)шEKB`РA ݤK^XgK2K~{Mӆ6U\R)+EtT_ubs4.!uJܸq5k }$5X\R/B{-BnJLh5G>[ $|4Lz@Qip ^?"!(Y$Pk³:ϣ *(8~ [1u1-qWLׂJn+G0o/  r.F~ۄMPd$XmQcqk)uxÔZ&b.غ֞YTTt4**~W2)"OT}32nAv цxT7|n?A;v,liQѥ3f{ƘânŢRe ._xZm1H)K[e`]fRёwfu?~% f}7o^>^lJ5]T4[ Dj2w"#t6,"\5c0pm4eLqGk G5']`@v&ํS...NɀYa0k`mK@460IBA… #dlPrdѢE{`&hKT+(LRMgݮ+\LPdq# к3- .,^x?HͻW'<@B1 A %&`ĝ@`e Yh 'Xg& A bB D8oZN$UloS*-ɂ B UֱT7%vj ׻)VhXQU6Ɩ5a5(Bvo>$Y#{cDj"m' 8TiH^;&Dλ`h-I,H$;hf$JSͤJg ]w~@yveΠWe'" @ Jeh#=JqS<%En[ +<юWGZjGλ FxyP2[!qCGKz+"m2#R 4?|̢lN aD@['W`&! |7q{2P LXe^n8D&h) sڤ^4)YbōFm q-4 %o{ޕN+HdBTgHV<>1 $#+]6вZN[UVX!E2XG2&Hg7Mjz )6g#=IԧEA0rcRXDcXT6d*k֜$@f1"3If㨹G VQ`$ d#tq^&q2uDڍH*Ca%)&Jd^*)@ @ @ @ @ @ @ @ @ @ @ C. eIENDB`python-gvm-24.8.0/docs/index.rst000066400000000000000000000012501466406635600165240ustar00rootroot00000000000000Greenbone Vulnerability Management Python Library ================================================= **python-gvm** is the official python library to control Greenbone Community Edition installations and Greenbone Enterprise Appliances remotely. .. note:: **python-gvm** requires at least Python 3.9. Python 2 is not supported. User Guide ---------- This sections explains how to install **python-gvm** and shows example use cases. .. toctree:: :maxdepth: 2 install usage The API Documentation --------------------- Information about specific functions, classes, or methods can be found in this part of the documentation. .. toctree:: :maxdepth: 2 api/api python-gvm-24.8.0/docs/install.rst000066400000000000000000000025261466406635600170720ustar00rootroot00000000000000.. _install: Installation of python-gvm ========================== For installing the latest stable release of **python-gvm**, `pip`_, `poetry`_ or `pipenv`_ can be used. If an application or library that uses **python-gvm** internally is developed, it is often better to choose `poetry`_ for handling the dependencies. Using pip --------- For installing **python-gvm** using `pip`_ run:: python3 -m pip install python-gvm Using poetry ------------ For installing **python-gvm** using `poetry`_ run:: poetry add python-gvm If the usage of `poetry`_ is not familiar, its documentation can be found at https://python-poetry.org/docs/. Using pipenv ------------ For installing **python-gvm** using `pipenv`_ run:: pipenv install python-gvm If `pipenv`_ is not used yet, head over to the pipenv website for installation instructions. Getting the Source ------------------ The source code of **python-gvm** can be found at `GitHub `_. 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:: python3 -m 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-24.8.0/docs/requirements.txt000066400000000000000000000000451466406635600201500ustar00rootroot00000000000000lxml paramiko defusedxml sphinx furo python-gvm-24.8.0/docs/usage.rst000066400000000000000000000256731466406635600165400ustar00rootroot00000000000000.. _usage: Usage ===== 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 ``/run/gvmd/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 = '/run/gvmd/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 = '/run/gvmd/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 = '/run/gvmd/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 = '/run/gvmd/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 = '/run/gvmd/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-24.8.0/gvm/000077500000000000000000000000001466406635600145265ustar00rootroot00000000000000python-gvm-24.8.0/gvm/__init__.py000066400000000000000000000006611466406635600166420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """ 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-24.8.0/gvm/__version__.py000066400000000000000000000001471466406635600173630ustar00rootroot00000000000000# pylint: disable=invalid-name # THIS IS AN AUTOGENERATED FILE. DO NOT TOUCH! __version__ = "24.8.0" python-gvm-24.8.0/gvm/_enum.py000066400000000000000000000022511466406635600162030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from enum import Enum as PythonEnum from typing import Any, Optional, Type, TypeVar from gvm.errors import InvalidArgument Self = TypeVar("Self", bound="Enum") class Enum(PythonEnum): """ Base class for Enums in python-gvm """ @classmethod def _missing_(cls: Type[Self], value: Any) -> Optional[Self]: if isinstance(value, PythonEnum): return cls.from_string(value.name) return cls.from_string(str(value) if value else None) @classmethod def from_string( cls: Type[Self], value: Optional[str], ) -> Optional[Self]: """ Convert a string value into an Enum instance If value is None or empty None is returned """ if not value: return None try: return cls[value.replace(" ", "_").upper()] except KeyError: raise InvalidArgument( f"Invalid argument {value}. " f"Allowed values are {','.join(e.name for e in cls)}." ) from None def __str__(self) -> str: return self.value python-gvm-24.8.0/gvm/connections/000077500000000000000000000000001466406635600170505ustar00rootroot00000000000000python-gvm-24.8.0/gvm/connections/__init__.py000066400000000000000000000014521466406635600211630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from ._connection import DEFAULT_TIMEOUT, GvmConnection from ._debug import DebugConnection from ._ssh import ( DEFAULT_HOSTNAME, DEFAULT_KNOWN_HOSTS_FILE, DEFAULT_SSH_PASSWORD, DEFAULT_SSH_PORT, DEFAULT_SSH_USERNAME, SSHConnection, ) from ._tls import DEFAULT_GVM_PORT, TLSConnection from ._unix import DEFAULT_UNIX_SOCKET_PATH, UnixSocketConnection __all__ = ( "DEFAULT_TIMEOUT", "DEFAULT_UNIX_SOCKET_PATH", "DEFAULT_GVM_PORT", "DEFAULT_HOSTNAME", "DEFAULT_KNOWN_HOSTS_FILE", "DEFAULT_SSH_PASSWORD", "DEFAULT_SSH_USERNAME", "DEFAULT_SSH_PORT", "DebugConnection", "GvmConnection", "SSHConnection", "TLSConnection", "UnixSocketConnection", ) python-gvm-24.8.0/gvm/connections/_connection.py000066400000000000000000000065621466406635600217310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import logging import socket as socketlib from abc import ABC, abstractmethod from time import time from typing import Optional, Protocol, Union, runtime_checkable from gvm.errors import GvmError BUF_SIZE = 16 * 1024 DEFAULT_TIMEOUT = 60 # in seconds logger = logging.getLogger(__name__) @runtime_checkable class GvmConnection(Protocol): """ Python `protocol `_ for GvmConnection classes. """ def connect(self) -> None: """Establish a connection to a remote server""" def disconnect(self) -> None: """Send data to the connected remote server Arguments: data: Data to be send to the server. Either utf-8 encoded string or bytes. """ def send(self, data: bytes) -> None: """Send data to the connected remote server Args: data: Data to be send to the server as bytes. """ def read(self) -> bytes: """Read data from the remote server Returns: data as bytes """ def finish_send(self): """Indicate to the remote server you are done with sending data""" class AbstractGvmConnection(ABC): """ 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[Union[int, float]] = DEFAULT_TIMEOUT): self._socket: Optional[socketlib.SocketType] = None self._timeout = timeout if timeout is not None else DEFAULT_TIMEOUT def _read(self) -> bytes: if self._socket is None: raise GvmError("Socket is not connected") return self._socket.recv(BUF_SIZE) @abstractmethod def connect(self) -> None: """Establish a connection to a remote server""" raise NotImplementedError def send(self, data: bytes) -> None: """Send data to the connected remote server Args: data: Data to be send to the server as bytes. """ if self._socket is None: raise GvmError("Socket is not connected") self._socket.sendall(data) def read(self) -> bytes: """Read data from the remote server Returns: data as bytes """ break_timeout = ( time() + self._timeout if self._timeout is not None else None ) data = self._read() if not data: # Connection was closed by server raise GvmError("Remote closed the connection") if break_timeout and time() > break_timeout: raise GvmError("Timeout while reading the response") return data 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) def finish_send(self): """Indicate to the remote server you are done with sending data""" if self._socket is not None: # shutdown socket for sending. only allow reading data afterwards self._socket.shutdown(socketlib.SHUT_WR) python-gvm-24.8.0/gvm/connections/_debug.py000066400000000000000000000035641466406635600206570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import logging from ._connection import GvmConnection logger = logging.getLogger("gvm.connections.debug") 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. Example: .. code-block:: python import logging logging.basicConfig(level=logging.DEBUG) socket_connection = UnixSocketConnection(path='/var/run/gvm.sock') connection = DebugConnection(socket_connection) gmp = Gmp(connection=connection) .. _logging: https://docs.python.org/3/library/logging.html """ def __init__(self, connection: GvmConnection): """ Create a new DebugConnection instance. Args: connection: GvmConnection to observe """ self._connection = connection def read(self) -> bytes: data = self._connection.read() logger.debug("Read %s characters. Data %r", len(data), data) self.last_read_data = data return data def send(self, data: bytes) -> None: self.last_send_data = data logger.debug("Sending %s characters. Data %r", len(data), data) return self._connection.send(data) def connect(self) -> None: logger.debug("Connecting") return self._connection.connect() def disconnect(self) -> None: logger.debug("Disconnecting") return self._connection.disconnect() def finish_send(self) -> None: logger.debug("Finish send") self._connection.finish_send() python-gvm-24.8.0/gvm/connections/_ssh.py000066400000000000000000000271271466406635600203670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import base64 import errno import hashlib import logging import socket as socketlib import sys from os import PathLike from pathlib import Path from time import time from typing import Any, Callable, Optional, TextIO, Union import paramiko import paramiko.ssh_exception import paramiko.transport from gvm.errors import GvmError from ._connection import BUF_SIZE, DEFAULT_TIMEOUT logger = logging.getLogger("gvm.connections.ssh") DEFAULT_SSH_PORT = 22 DEFAULT_SSH_USERNAME = "gmp" DEFAULT_SSH_PASSWORD = "" DEFAULT_HOSTNAME = "127.0.0.1" DEFAULT_KNOWN_HOSTS_FILE = ".ssh/known_hosts" class SSHConnection: """ SSH Class to connect, read and write from GVM via SSH """ def __init__( self, *, timeout: Optional[Union[int, float]] = 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[Union[str, PathLike]] = None, auto_accept_host: Optional[bool] = None, file: TextIO = sys.stdout, input: Callable[[], str] = input, exit: Callable[[str], Any] = sys.exit, ) -> None: """ Create a new SSH connection instance. Args: 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: Password to use for SSH login. Default is "". """ self._client: Optional[paramiko.SSHClient] = None 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 ) self.auto_accept_host = auto_accept_host self._timeout = timeout self._file = file self._input = input self._exit = exit def _send_all(self, data: bytes) -> 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 _auto_accept_host( self, hostkeys: paramiko.HostKeys, key: paramiko.PKey ) -> None: if self.port == DEFAULT_SSH_PORT: hostkeys.add(self.hostname, key.get_name(), key) elif self.port != DEFAULT_SSH_PORT: hostkeys.add( "[" + self.hostname + "]:" + str(self.port), key.get_name(), key, ) try: hostkeys.save(filename=str(self.known_hosts_file)) except OSError as e: raise GvmError( "Something went wrong with writing " f"the known_hosts file {self.known_hosts_file.absolute()}: {e}" ) from None key_type = key.get_name().replace("ssh-", "").upper() logger.info( "Warning: Permanently added '%s' (%s) to " "the list of known hosts.", self.hostname, key_type, ) 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.", file=self._file, ) print( f"{key_type} key fingerprint is {sha64_fingerprint}.", file=self._file, ) print( "Are you sure you want to continue connecting (yes/no)? ", end="", file=self._file, ) add = self._input() while True: if add == "yes": if self.port == DEFAULT_SSH_PORT: hostkeys.add(self.hostname, key.get_name(), key) elif self.port != DEFAULT_SSH_PORT: hostkeys.add( "[" + self.hostname + "]:" + str(self.port), 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="", file=self._file, ) save = self._input() while True: if save == "yes": try: hostkeys.save(filename=str(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="", file=self._file, ) save = self._input() break elif add == "no": self._exit("User denied key. Host key verification failed.") else: print("Please type 'yes' or 'no': ", end="", file=self._file) add = self._input() def _get_remote_host_key(self) -> paramiko.PKey: """Get the remote host key for ssh connection""" try: tmp_socket = socketlib.socket() tmp_socket.settimeout(self._timeout) tmp_socket.connect((self.hostname, self.port)) except OSError as e: tmp_socket.close() 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: tmp_socket.close() 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 finally: tmp_socket.close() return key def _ssh_authentication(self) -> None: """Search/add/save the servers key for the SSH authentication process""" if not self._client: raise GvmError("SSH Client not connected.") # set to reject policy (avoid MITM attacks) self._client.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._client.load_host_keys(filename=str(self.known_hosts_file)) except OSError as e: if e.errno != errno.ENOENT: raise GvmError( "Something went wrong with reading " f"the known_hosts file: {e}" ) from None hostkeys = self._client.get_host_keys() # Switch based on SSH Port if self.port == DEFAULT_SSH_PORT: hostname = self.hostname else: hostname = f"[{self.hostname}]:{self.port}" if not hostkeys.lookup(hostname): # Key not found, so connect to remote and fetch the key # with the paramiko Transport protocol key = self._get_remote_host_key() if self.auto_accept_host: self._auto_accept_host(hostkeys=hostkeys, key=key) else: self._ssh_authentication_input_loop(hostkeys=hostkeys, key=key) def _read(self) -> bytes: return self._stdout.channel.recv(BUF_SIZE) def send(self, data: bytes) -> None: self._send_all(data) def read(self) -> bytes: break_timeout = ( time() + self._timeout if self._timeout is not None else None ) data = self._read() if not data: # Connection was closed by server raise GvmError("Remote closed the connection") if break_timeout and time() > break_timeout: raise GvmError("Timeout while reading the response") return data def connect(self) -> None: """ Connect to the SSH server and authenticate to it """ self._client = paramiko.SSHClient() self._ssh_authentication() try: self._client.connect( hostname=self.hostname, username=self.username, password=self.password, timeout=self._timeout, port=int(self.port), allow_agent=False, look_for_keys=False, ) except ( paramiko.BadHostKeyException, paramiko.AuthenticationException, paramiko.SSHException, paramiko.ssh_exception.NoValidConnectionsError, ConnectionError, ) as e: raise GvmError(f"SSH Connection failed: {e}") from None self._stdin, self._stdout, self._stderr = self._client.exec_command( "", get_pty=False ) def disconnect(self) -> None: """Disconnect and close the connection to the remote server""" try: if self._client is not None: self._client.close() except OSError as e: logger.debug("Connection closing error: %s", e) raise e if self._client is not None: self._client = None del self._stdin, self._stdout, self._stderr def finish_send(self) -> None: # shutdown socket for sending. only allow reading data afterwards self._stdout.channel.shutdown(socketlib.SHUT_WR) python-gvm-24.8.0/gvm/connections/_tls.py000066400000000000000000000070321466406635600203650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import logging import socket as socketlib import ssl from typing import Optional, Union from ._connection import DEFAULT_TIMEOUT, AbstractGvmConnection DEFAULT_GVM_PORT = 9390 DEFAULT_HOSTNAME = "127.0.0.1" DEFAULT_KNOWN_HOSTS_FILE = ".ssh/known_hosts" logger = logging.getLogger("gvm.connections.tls") class TLSConnection(AbstractGvmConnection): """ TLS class to connect, read and write from a remote GVM daemon via TLS secured socket. """ 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[Union[int, float]] = DEFAULT_TIMEOUT, ) -> None: """ Create a new TLSConnection instance. Args: 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 """ 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) -> ssl.SSLSocket: 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, ) context.minimum_version = ssl.TLSVersion.TLSv1_2 else: context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) context.minimum_version = ssl.TLSVersion.TLSv1_2 context.check_hostname = False context.verify_mode = ssl.CERT_NONE sock = context.wrap_socket(transport_socket, server_side=False) sock.settimeout(self._timeout) return sock def connect(self) -> None: self._socket = self._new_socket() self._socket.connect((self.hostname, int(self.port))) def disconnect(self): """Close the SSL layer then disconnect from the remote server""" try: if self._socket is not None: self._socket = self._socket.unwrap() except OSError as e: logger.debug("Connection closing error: %s", e) return super().disconnect() python-gvm-24.8.0/gvm/connections/_unix.py000066400000000000000000000031651466406635600205510ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import socket as socketlib from os import PathLike, fspath from typing import Optional, Union from gvm.errors import GvmError from ._connection import DEFAULT_TIMEOUT, AbstractGvmConnection DEFAULT_UNIX_SOCKET_PATH = "/run/gvmd/gvmd.sock" class UnixSocketConnection(AbstractGvmConnection): """ UNIX-Socket class to connect, read, write from a daemon via direct communicating UNIX-Socket """ def __init__( self, *, path: Optional[Union[str, PathLike[str]]] = DEFAULT_UNIX_SOCKET_PATH, timeout: Optional[Union[int, float]] = DEFAULT_TIMEOUT, ) -> None: """ Create a new UnixSocketConnection instance. Args: path: Path to the socket. Default is "/run/gvmd/gvmd.sock". timeout: Timeout in seconds for the connection. Default is 60 seconds. """ super().__init__(timeout=timeout) self.path = ( fspath(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 as e: raise GvmError( f"Could not connect to socket {self.path}. Error was {e}" ) from None python-gvm-24.8.0/gvm/errors.py000066400000000000000000000123051466406635600164150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """ 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: Optional[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: Optional[str] = None, message: Optional[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: Optional[str] = None, message: Optional[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, *, arg_type: Optional[str] = None, function: Optional[str] = None, ): super().__init__(None) self.argument = argument self.function = function self.arg_type = arg_type def __str__(self): if self.function: if self.arg_type: return ( f"In {self.function} the argument {self.argument} " f"must be of type {self.arg_type}." ) return ( f"Invalid argument type for argument {self.argument} in " f"{self.function}." ) if self.arg_type: return ( f"The argument {self.argument} must be of type {self.arg_type}." ) return f"Invalid argument type for argument {self.argument}." 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-24.8.0/gvm/protocols/000077500000000000000000000000001466406635600165525ustar00rootroot00000000000000python-gvm-24.8.0/gvm/protocols/__init__.py000066400000000000000000000007301466406635600206630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """ Package for supported Greenbone Protocol versions. Currently `GMP version 22.04`_, `GMP version 22.05`_ and `OSP version 1`_ are supported. .. _GMP version 22.04: https://docs.greenbone.net/API/GMP/gmp-22.04.html .. _GMP version 22.05: https://docs.greenbone.net/API/GMP/gmp-22.05.html .. _OSP version 1: https://docs.greenbone.net/API/OSP/osp-1.2.html """ python-gvm-24.8.0/gvm/protocols/_protocol.py000066400000000000000000000100521466406635600211220ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from types import TracebackType from typing import Callable, Generic, Optional, Type, TypeVar from gvm.connections import GvmConnection from .core import Connection, Request, Response T = TypeVar("T") Self = TypeVar("Self", bound="GvmProtocol") def str_transform(response: Response) -> str: return str(response) class GvmProtocol(Generic[T]): """Base class for different GVM protocols""" def __init__( self, connection: GvmConnection, *, transform: Callable[[Response], T] = str_transform, # type: ignore[assignment] ): """ Create a new GvmProtocol instance. Args: 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. """ self._connection = connection self._protocol = Connection() self._connected = False self._transform_callable = transform def __enter__(self: Self) -> Self: self.connect() return self def __exit__( self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType], ) -> None: self.disconnect() def _read(self) -> bytes: """Read a command response from gvmd Returns: str: Response from server. """ return self._connection.read() def _send(self, data: bytes) -> None: """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 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) -> None: """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) -> None: """Disconnect the connection Ends and closes the connection. """ if self.is_connected(): self._connection.disconnect() self._connected = False self._protocol.close() def send_command(self, cmd: str) -> str: """ Send a string command to the remote daemon and return the response as string """ return bytes( self._send_command(cmd.encode("utf-8", errors="ignore")) # type: ignore[arg-type] # it seems mypy on Python < 3.11 can't handle bytes here ).decode("utf-8", errors="ignore") def _transform(self, response: Response) -> T: transform = self._transform_callable return transform(response) def _send_command(self, cmd: Request) -> Response: try: send_data = self._protocol.send(cmd) self._send(send_data) response: Optional[Response] = None while not response: received_data = self._read() response = self._protocol.receive_data(received_data) return response except Exception as e: self.disconnect() raise e def _send_and_transform_command(self, cmd: Request) -> T: return self._transform(self._send_command(cmd)) python-gvm-24.8.0/gvm/protocols/core/000077500000000000000000000000001466406635600175025ustar00rootroot00000000000000python-gvm-24.8.0/gvm/protocols/core/__init__.py000066400000000000000000000005111466406635600216100ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from ._connection import Connection, InvalidStateError from ._request import Request from ._response import Response, StatusError __all__ = ( "Connection", "InvalidStateError", "Request", "Response", "StatusError", ) python-gvm-24.8.0/gvm/protocols/core/_connection.py000066400000000000000000000131501466406635600223520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import AnyStr, Optional, Protocol from lxml import etree from gvm.errors import GvmError from ._request import Request from ._response import Response class XmlReader: """ Read a XML command until its closing element """ def start_xml(self) -> None: self._first_element: Optional[etree._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) -> bool: for action, obj in self._parser.read_events(): if not self._first_element and action in "start": self._first_element = obj.tag # type: ignore if ( self._first_element and action in "end" and str(self._first_element) == str(obj.tag) # type: ignore ): return True return False def feed_xml(self, data: AnyStr) -> None: try: self._parser.feed(data) except etree.ParseError as e: raise GvmError( f"Cannot parse XML response. Response data read {data!r}", e, ) from None class InvalidStateError(GvmError): """ Error raised if the Connection would be moved into an invalid state """ def __init__(self, message: str = "Invalid State", *args): super().__init__(message, *args) class State(Protocol): def __set_context__(self, context: "Context") -> None: ... def send(self, request: Request) -> bytes: ... def receive_data(self, data: bytes) -> Optional[Response]: ... def close(self) -> None: ... class Context(Protocol): def __set_state__(self, state: State) -> None: ... class AbstractState: _context: Context def __set_context__(self, context: Context) -> None: self._context = context def set_next_state(self, next_state: State) -> None: self._context.__set_state__(next_state) class InitialState(AbstractState): def send(self, request: Request) -> bytes: self.set_next_state(AwaitingResponseState(request)) return bytes(request) def receive_data(self, data: bytes) -> Optional[Response]: raise InvalidStateError() def close(self) -> None: # nothing to do return class AwaitingResponseState(AbstractState): def __init__(self, request: Request) -> None: self._request = request def send(self, request: Request) -> bytes: raise InvalidStateError() def close(self) -> None: self.set_next_state(InitialState()) def receive_data(self, data: bytes) -> Optional[Response]: next_state = ReceivingDataState(self._request) self.set_next_state(next_state) return next_state.receive_data(data) class ErrorState(AbstractState): message = ( "The connection is in an error state. Please close the connection." ) def send(self, request: Request) -> bytes: raise InvalidStateError(self.message) def close(self) -> None: self.set_next_state(InitialState()) def receive_data(self, data: bytes) -> Optional[Response]: raise InvalidStateError(self.message) class ReceivingDataState(AbstractState): def __init__(self, request: Request) -> None: self._request = request self._data = bytearray() self._reader = XmlReader() self._reader.start_xml() def send(self, request: Request) -> bytes: raise InvalidStateError() def close(self) -> None: self.set_next_state(InitialState()) def receive_data(self, data: bytes) -> Optional[Response]: self._data += data try: self._reader.feed_xml(data) except GvmError as e: self.set_next_state(ErrorState()) raise e if not self._reader.is_end_xml(): return None self.set_next_state(InitialState()) return Response(data=bytes(self._data), request=self._request) class Connection: """ This is a [SansIO](https://sans-io.readthedocs.io) connection for GMP It is responsible for creating bytes from GMP XML requests and transforming XML response data into GMP responses. """ def __init__(self) -> None: self.__set_state__(InitialState()) def send(self, request: Request) -> bytes: """ Create data from a request to be send Returns: The data for a request that can be send for example over a socket Raises: An InvalidStateError if no request can be send currently. For example when waiting for a response to a previous request. """ return self._state.send(request) def receive_data(self, data: bytes) -> Optional[Response]: """ Feed received data a response is complete Returns: A Response if the response data is complete and None if data is still to be received. Raises: An InvalidStateError if no data can be received currently. For example if not request is send yet. """ return self._state.receive_data(data) def close(self) -> None: """ Close the connection and reset the state of the protocol Afterwards the connection can be reused for sending a new request. """ return self._state.close() def __set_state__(self, state: State) -> None: self._state = state self._state.__set_context__(self) python-gvm-24.8.0/gvm/protocols/core/_request.py000066400000000000000000000005221466406635600217020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Protocol, runtime_checkable @runtime_checkable class Request(Protocol): """ A GMP Request Python Protocol A Request implementation may be provided by several classes """ def __bytes__(self) -> bytes: ... python-gvm-24.8.0/gvm/protocols/core/_response.py000066400000000000000000000053661466406635600220630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from functools import cached_property from typing import Optional, TypeVar from gvm.errors import GvmError from gvm.xml import Element, parse_xml from ._request import Request class StatusError(GvmError): """ The response had an error status May be raised when calling `response.raise_for_status()` """ def __init__(self, message: Optional[str], *args, response: "Response"): super().__init__(message, *args) self.response = response self.request = response.request Self = TypeVar("Self", bound="Response") class Response: """ A GMP Response """ def __init__(self, *, request: Request, data: bytes) -> None: """ Create a Response object Args: request: The request corresponding to this response data: The data of the response """ self._request = request self._data = data self.__xml: Optional[Element] = None def __root_element(self) -> Element: if self.__xml is None: self.__xml = self.xml() return self.__xml def xml(self) -> Element: """ Return the response data as XML Element Raises XmlError if the data is not valid XML. """ return parse_xml(self.data) @property def data(self) -> bytes: """ Return the data of the response as bytes """ return self._data @property def request(self) -> Request: """ Return the corresponding request of this response """ return self._request @cached_property def status_code(self) -> Optional[int]: """ The status code of the response Returns: The status code or None if the response data doesn't contain a valid status code. """ root = self.__root_element() try: status = root.attrib["status"] return int(status) except (KeyError, ValueError): return None @property def is_success(self) -> bool: """ Returns True if the response contains a success status code """ status = self.status_code return status is not None and 200 <= status <= 299 def raise_for_status(self: Self) -> Self: if self.is_success: return self raise StatusError( f"Invalid status code {self.status_code}", response=self ) def __bytes__(self) -> bytes: """ Return the data as bytes """ return self._data def __str__(self) -> str: """ Return the data as string """ return self._data.decode() python-gvm-24.8.0/gvm/protocols/gmp/000077500000000000000000000000001466406635600173355ustar00rootroot00000000000000python-gvm-24.8.0/gvm/protocols/gmp/__init__.py000066400000000000000000000014151466406635600214470ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later """ Protocol implementations for the Greenbone Management Protocol (GMP). In most circumstances you will want to use the :class:`GMP` class which dynamically selects the supported GMP protocol of the remote manager daemon. If you need to use a specific GMP version, you can use the :class:`GMPv224` or :class:`GMPv225` classes. * :class:`GMP` - Dynamically select supported GMP protocol of the remote manager daemon. * :class:`GMPv224` - GMP version 22.4 * :class:`GMPv225` - GMP version 22.5 """ from ._gmp import GMP from ._gmp224 import GMPv224 from ._gmp225 import GMPv225 Gmp = GMP # for backwards compatibility __all__ = ( "GMP", "Gmp", "GMPv224", "GMPv225", ) python-gvm-24.8.0/gvm/protocols/gmp/_gmp.py000066400000000000000000000076701466406635600206430ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from types import TracebackType from typing import Callable, Optional, Type, Union from gvm.connections import GvmConnection from gvm.errors import GvmError from gvm.protocols.core import Response from .._protocol import GvmProtocol, T, str_transform from ._gmp224 import GMPv224 from ._gmp225 import GMPv225 from .requests import Version SUPPORTED_GMP_VERSIONS = Union[GMPv224[T], GMPv225[T]] class GMP(GvmProtocol[T]): """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.gmp.GMPv224 or # gvm.protocols.gmp.GMPv225 depending # on the supported GMP version of the remote manager daemon resp = gmp.get_tasks() """ def __init__( self, connection: GvmConnection, *, transform: Callable[[Response], T] = str_transform, # type: ignore[assignment] ): """ Create a new GMP instance. Args: 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 """ super().__init__(connection, transform=transform) self._gmp: Optional[SUPPORTED_GMP_VERSIONS] = None def determine_remote_gmp_version(self) -> str: """Determine the supported GMP version of the remote daemon""" self.connect() resp = self._send_command(Version.get_version()) self.disconnect() version_el = resp.xml().find("version") if version_el is None or not version_el.text: 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_str = self.determine_remote_gmp_version().split(".", 1) major_version = int(version_str[0]) minor_version = int(version_str[1]) if major_version == 22 and minor_version == 4: gmp_class = GMPv224 elif major_version == 22 and minor_version == 5: gmp_class = GMPv225 else: raise GvmError( "Remote manager daemon uses an unsupported version of GMP. " f"The GMP version was {major_version}.{minor_version}" ) return gmp_class(self._connection, transform=self._transform_callable) # type: ignore[arg-type] def __enter__(self) -> SUPPORTED_GMP_VERSIONS: # type: ignore[override] """ Returns the corresponding GMP class of the supported GMP version of the remote manager daemon. """ self._gmp = self.determine_supported_gmp() self._gmp.connect() return self._gmp def __exit__( self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], traceback: Optional[TracebackType], ) -> None: if self._gmp: self._gmp.disconnect() self._gmp = None python-gvm-24.8.0/gvm/protocols/gmp/_gmp224.py000066400000000000000000004346541466406635600211010ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later """ Greenbone Management Protocol (GMP) version 22.4 """ from typing import Iterable, Mapping, Optional, Sequence, Union from gvm.utils import SupportsStr, to_dotted_types_dict from .._protocol import GvmProtocol, T from .requests.v224 import ( Aggregates, AggregateStatistic, AlertCondition, AlertEvent, AlertMethod, Alerts, AliveTest, Audits, Authentication, CertBundAdvisories, Cpes, CredentialFormat, Credentials, CredentialType, Cves, DfnCertAdvisories, EntityID, EntityType, Feed, FeedType, Filters, FilterType, Groups, Help, HelpFormat, Hosts, HostsOrdering, InfoType, Notes, Nvts, OperatingSystems, Overrides, Permissions, PermissionSubjectType, Policies, PortLists, PortRangeType, ReportFormats, ReportFormatType, Reports, Results, Roles, ScanConfigs, Scanners, ScannerType, Schedules, SecInfo, Severity, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, SortOrder, SystemReports, Tags, Targets, Tasks, Tickets, TicketStatus, TLSCertificates, TrashCan, UserAuthType, Users, UserSettings, Version, Vulnerabilities, ) _TYPE_FIELDS = [ AggregateStatistic, AlertCondition, AlertEvent, AlertMethod, AliveTest, CredentialFormat, CredentialType, EntityType, FeedType, FilterType, HostsOrdering, InfoType, HelpFormat, PortRangeType, PermissionSubjectType, ReportFormatType, ScannerType, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, SortOrder, TicketStatus, UserAuthType, ] class GMPv224(GvmProtocol[T]): """ A class implementing the Greenbone Management Protocol (GMP) version 22.4 Example: .. code-block:: python from gvm.protocols.gmp import GMPv224 as GMP with GMP(connection) as gmp: resp = gmp.get_tasks() """ _authenticated = False def __init__(self, *args, **kwargs): """ Create a new GMPv224 instance. Args: 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 """ super().__init__(*args, **kwargs) self.types = to_dotted_types_dict(_TYPE_FIELDS) @staticmethod def get_protocol_version() -> tuple[int, int]: """ Return the supported GMP version as major, minor version tuple """ return (22, 4) 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) -> T: """Authenticate to gvmd. The generated authenticate command will be send to server. Afterwards the response is read, transformed and returned. Args: username: Username password: Password """ response = self._send_command( Authentication.authenticate(username=username, password=password) ) if response.is_success: self._authenticated = True return self._transform(response) def describe_auth(self) -> T: """Describe authentication methods Returns a list of all used authentication methods if such a list is available. """ return self._send_and_transform_command(Authentication.describe_auth()) def modify_auth( self, group_name: str, auth_conf_settings: dict[str, str] ) -> T: """Modifies an existing auth. Args: group_name: Name of the group to be modified. auth_conf_settings: The new auth config. """ return self._send_and_transform_command( Authentication.modify_auth(group_name, auth_conf_settings) ) def get_version(self) -> T: """Get the Greenbone Vulnerability Management Protocol (GMP) version used by the remote gvmd. """ return self._send_and_transform_command(Version.get_version()) def clone_port_list(self, port_list_id: EntityID) -> T: """Clone an existing port list Args: port_list_id: UUID of an existing port list to clone from """ return self._send_and_transform_command( PortLists.clone_port_list(port_list_id) ) def create_port_list( self, name: str, port_range: str, *, comment: Optional[str] = None ) -> T: """Create a new port list Args: 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 """ return self._send_and_transform_command( PortLists.create_port_list(name, port_range, comment=comment) ) def create_port_range( self, port_list_id: EntityID, start: int, end: int, port_range_type: Union[str, PortRangeType], *, comment: Optional[str] = None, ) -> T: """Create new port range Args: 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 """ return self._send_and_transform_command( PortLists.create_port_range( port_list_id, start, end, port_range_type, comment=comment ) ) def delete_port_list( self, port_list_id: EntityID, *, ultimate: bool = False ) -> T: """Delete an existing port list Args: port_list_id: UUID of the port list to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( PortLists.delete_port_list(port_list_id, ultimate=ultimate) ) def delete_port_range(self, port_range_id: EntityID) -> T: """Delete an existing port range Args: port_range_id: UUID of the port range to be deleted. """ return self._send_and_transform_command( PortLists.delete_port_range(port_range_id) ) def get_port_lists( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, targets: Optional[bool] = None, trash: Optional[bool] = None, ) -> T: """Request a list of port lists Args: 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 """ return self._send_and_transform_command( PortLists.get_port_lists( filter_string=filter_string, filter_id=filter_id, details=details, targets=targets, trash=trash, ) ) def get_port_list(self, port_list_id: EntityID) -> T: """Request a single port list Args: port_list_id: UUID of an existing port list """ return self._send_and_transform_command( PortLists.get_port_list(port_list_id) ) def modify_port_list( self, port_list_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, ) -> T: """Modify an existing port list. Args: port_list_id: UUID of port list to modify. name: Name of port list. comment: Comment on port list. """ return self._send_and_transform_command( PortLists.modify_port_list(port_list_id, comment=comment, name=name) ) def get_aggregates( self, resource_type: Union[EntityType, str], *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, sort_criteria: Optional[ Iterable[dict[str, Union[str, SortOrder, AggregateStatistic]]] ] = None, data_columns: Optional[Iterable[str]] = None, group_column: Optional[str] = None, subgroup_column: Optional[str] = None, text_columns: Optional[Iterable[str]] = None, first_group: Optional[int] = None, max_groups: Optional[int] = None, mode: Optional[int] = None, **kwargs, ) -> T: """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. Args: 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 """ return self._send_and_transform_command( Aggregates.get_aggregates( resource_type, filter_string=filter_string, filter_id=filter_id, sort_criteria=sort_criteria, data_columns=data_columns, group_column=group_column, subgroup_column=subgroup_column, text_columns=text_columns, first_group=first_group, max_groups=max_groups, mode=mode, **kwargs, ) ) def get_feeds(self) -> T: """Request the list of feeds""" return self._send_and_transform_command(Feed.get_feeds()) def get_feed(self, feed_type: Union[FeedType, str]) -> T: """Request a single feed Args: feed_type: Type of single feed to get: NVT, CERT or SCAP """ return self._send_and_transform_command(Feed.get_feed(feed_type)) def help( self, *, help_format: Optional[Union[HelpFormat, str]] = None, brief: Optional[bool] = None, ) -> T: """Get the help text Args: help_format: Format of of the help: "html", "rnc", "text" or "xml brief: If True help is brief """ return self._send_and_transform_command( Help.help(help_format=help_format, brief=brief) ) 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[EntityID] = None, ) -> T: """Request a list of system reports Args: 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 """ return self._send_and_transform_command( SystemReports.get_system_reports( name=name, duration=duration, start_time=start_time, end_time=end_time, brief=brief, slave_id=slave_id, ) ) def empty_trashcan(self) -> T: """Empty the trashcan Remove all entities from the trashcan. **Attention:** this command can not be reverted """ return self._send_and_transform_command(TrashCan.empty_trashcan()) def restore_from_trashcan(self, entity_id: EntityID) -> T: """Restore an entity from the trashcan Args: entity_id: ID of the entity to be restored from the trashcan """ return self._send_and_transform_command( TrashCan.restore_from_trashcan(entity_id) ) def get_user_settings(self, *, filter_string: Optional[str] = None) -> T: """Request a list of user settings Args: filter_string: Filter term to use for the query """ return self._send_and_transform_command( UserSettings.get_user_settings(filter_string=filter_string) ) def get_user_setting(self, setting_id: EntityID) -> T: """Request a single user setting Args: setting_id: UUID of an existing setting """ return self._send_and_transform_command( UserSettings.get_user_setting(setting_id) ) def modify_user_setting( self, *, setting_id: Optional[EntityID] = None, name: Optional[str] = None, value: Optional[str] = None, ) -> T: """Modifies an existing user setting. Args: 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. """ return self._send_and_transform_command( UserSettings.modify_user_setting( setting_id=setting_id, name=name, value=value ) ) def clone_scan_config(self, config_id: EntityID) -> T: """Clone a scan config from an existing one Args: config_id: UUID of the existing scan config """ return self._send_and_transform_command( ScanConfigs.clone_scan_config(config_id) ) def create_scan_config( self, config_id: EntityID, name: str, *, comment: Optional[str] = None, ) -> T: """Create a new scan config Args: config_id: UUID of the existing scan config name: Name of the new scan config comment: A comment on the config """ return self._send_and_transform_command( ScanConfigs.create_scan_config(config_id, name, comment=comment) ) def delete_scan_config( self, config_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing config Args: config_id: UUID of the config to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( ScanConfigs.delete_scan_config(config_id, ultimate=ultimate) ) def get_scan_configs( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, details: Optional[bool] = None, families: Optional[bool] = None, preferences: Optional[bool] = None, tasks: Optional[bool] = None, ) -> T: """Request a list of scan configs Args: 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 """ return self._send_and_transform_command( ScanConfigs.get_scan_configs( filter_string=filter_string, filter_id=filter_id, trash=trash, details=details, families=families, preferences=preferences, tasks=tasks, ) ) def get_scan_config( self, config_id: EntityID, *, tasks: Optional[bool] = None ) -> T: """Request a single scan config Args: config_id: UUID of an existing scan config tasks: Whether to get tasks using this config """ return self._send_and_transform_command( ScanConfigs.get_scan_config(config_id, tasks=tasks) ) def get_scan_config_preferences( self, *, nvt_oid: Optional[str] = None, config_id: Optional[EntityID] = None, ) -> T: """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. Args: nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values """ return self._send_and_transform_command( ScanConfigs.get_scan_config_preferences( nvt_oid=nvt_oid, config_id=config_id ) ) def get_scan_config_preference( self, name: str, *, nvt_oid: Optional[str] = None, config_id: Optional[EntityID] = None, ) -> T: """Request a nvt preference Args: name: name of a particular preference nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values """ return self._send_and_transform_command( ScanConfigs.get_scan_config_preference( name, nvt_oid=nvt_oid, config_id=config_id ) ) def import_scan_config(self, config: str) -> T: """Import a scan config from XML Args: config: Scan Config XML as string to import. This XML must contain a :code:`` root element. """ return self._send_and_transform_command( ScanConfigs.import_scan_config(config) ) def modify_scan_config_set_nvt_preference( self, config_id: EntityID, name: str, nvt_oid: str, *, value: Optional[str] = None, ) -> T: """Modifies the nvt preferences of an existing scan config. Args: 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. """ return self._send_and_transform_command( ScanConfigs.modify_scan_config_set_nvt_preference( config_id, name, nvt_oid, value=value ) ) def modify_scan_config_set_name(self, config_id: EntityID, name: str) -> T: """Modifies the name of an existing scan config Args: config_id: UUID of scan config to modify. name: New name for the config. """ return self._send_and_transform_command( ScanConfigs.modify_scan_config_set_name(config_id, name) ) def modify_scan_config_set_comment( self, config_id: EntityID, *, comment: Optional[str] = None ) -> T: """Modifies the comment of an existing scan config Args: 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. """ return self._send_and_transform_command( ScanConfigs.modify_scan_config_set_comment( config_id, comment=comment ) ) def modify_scan_config_set_scanner_preference( self, config_id: EntityID, name: str, *, value: Optional[str] = None, ) -> T: """Modifies the scanner preferences of an existing scan config Args: 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. """ return self._send_and_transform_command( ScanConfigs.modify_scan_config_set_scanner_preference( config_id, name, value=value ) ) def modify_scan_config_set_nvt_selection( self, config_id: EntityID, family: str, nvt_oids: Union[tuple[str], list[str]], ) -> T: """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. """ return self._send_and_transform_command( ScanConfigs.modify_scan_config_set_nvt_selection( config_id, family, nvt_oids ) ) def modify_scan_config_set_family_selection( self, config_id: EntityID, families: list[tuple[str, bool, bool]], *, auto_add_new_families: Optional[bool] = True, ) -> T: """ Selected the NVTs of a scan config at a family level. Args: 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. """ return self._send_and_transform_command( ScanConfigs.modify_scan_config_set_family_selection( config_id, families, auto_add_new_families=auto_add_new_families ) ) def create_scanner( self, name: str, host: str, port: Union[str, int], scanner_type: ScannerType, credential_id: str, *, ca_pub: Optional[str] = None, comment: Optional[str] = None, ) -> T: """Create a new scanner Args: name: Name of the new scanner host: Hostname or IP address of the scanner port: 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 """ return self._send_and_transform_command( Scanners.create_scanner( name, host, port, scanner_type, credential_id, ca_pub=ca_pub, comment=comment, ) ) def modify_scanner( self, scanner_id: EntityID, *, name: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, scanner_type: Optional[ScannerType] = None, credential_id: Optional[EntityID] = None, ca_pub: Optional[str] = None, comment: Optional[str] = None, ) -> T: """Modify an existing scanner Args: scanner_id: UUID of the scanner to modify name: New name of the scanner host: New hostname or IP address of the scanner port: New port of the scanner scanner_type: New type of the scanner credential_id: New UUID of client certificate credential for the scanner ca_pub: New certificate of CA to verify scanner certificate comment: New comment for the scanner """ return self._send_and_transform_command( Scanners.modify_scanner( scanner_id, name=name, host=host, port=port, scanner_type=scanner_type, credential_id=credential_id, ca_pub=ca_pub, comment=comment, ) ) def get_scanners( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, details: Optional[bool] = None, ) -> T: """Request a list of scanners Args: 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 """ return self._send_and_transform_command( Scanners.get_scanners( filter_string=filter_string, filter_id=filter_id, trash=trash, details=details, ) ) def get_scanner(self, scanner_id: EntityID) -> T: """Request a single scanner Args: scanner_id: UUID of an existing scanner """ return self._send_and_transform_command( Scanners.get_scanner(scanner_id) ) def verify_scanner(self, scanner_id: EntityID) -> T: """Verify an existing scanner Args: scanner_id: UUID of an existing scanner """ return self._send_and_transform_command( Scanners.verify_scanner(scanner_id) ) def clone_scanner(self, scanner_id: EntityID) -> T: """Clone an existing scanner Args: scanner_id: UUID of an existing scanner """ return self._send_and_transform_command( Scanners.clone_scanner(scanner_id) ) def delete_scanner( self, scanner_id: EntityID, ultimate: Optional[bool] = False ) -> T: """Delete an existing scanner Args: scanner_id: UUID of an existing scanner """ return self._send_and_transform_command( Scanners.delete_scanner(scanner_id, ultimate=ultimate) ) def create_user( self, name: str, *, password: Optional[str] = None, hosts: Optional[list[str]] = None, hosts_allow: Optional[bool] = False, role_ids: Optional[list[EntityID]] = None, ) -> T: """Create a new user Args: 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. role_ids: A list of role UUIDs for the user """ return self._send_and_transform_command( Users.create_user( name, password=password, hosts=hosts, hosts_allow=hosts_allow, role_ids=role_ids, ) ) def modify_user( self, user_id: EntityID, *, name: Optional[str] = None, comment: Optional[str] = None, password: Optional[str] = None, auth_source: Optional[UserAuthType] = None, role_ids: Optional[list[EntityID]] = None, hosts: Optional[list[str]] = None, hosts_allow: Optional[bool] = False, group_ids: Optional[list[EntityID]] = None, ) -> T: """Modify 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. Args: 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. group_ids: List of group UUIDs for the user. """ return self._send_and_transform_command( Users.modify_user( user_id, name=name, comment=comment, password=password, auth_source=auth_source, role_ids=role_ids, hosts=hosts, hosts_allow=hosts_allow, group_ids=group_ids, ) ) def clone_user(self, user_id: EntityID) -> T: """Clone an existing user. Args: user_id: UUID of the user to be cloned. """ return self._send_and_transform_command(Users.clone_user(user_id)) def delete_user( self, user_id: Optional[EntityID] = None, *, name: Optional[str] = None, inheritor_id: Optional[EntityID] = None, inheritor_name: Optional[str] = None, ) -> T: """Delete an existing user Either user_id or name must be passed. Args: user_id: UUID of the task to be deleted. name: The name of the user to be deleted. inheritor_id: The UUID of the inheriting user or "self". Overrides inheritor_name. inheritor_name: The name of the inheriting user. """ return self._send_and_transform_command( Users.delete_user( user_id=user_id, name=name, inheritor_id=inheritor_id, inheritor_name=inheritor_name, ) ) def get_users( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, ) -> T: """Request a list of users Args: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query """ return self._send_and_transform_command( Users.get_users(filter_string=filter_string, filter_id=filter_id) ) def get_user(self, user_id: EntityID) -> T: """Request a single user Args: user_id: UUID of the user to be requested. """ return self._send_and_transform_command(Users.get_user(user_id)) def create_note( self, text: str, nvt_oid: str, *, days_active: Optional[int] = None, hosts: Optional[list[str]] = None, port: Optional[str] = None, result_id: Optional[EntityID] = None, severity: Optional[Severity] = None, task_id: Optional[EntityID] = None, ) -> T: """Create a new note Args: 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 host addresses port: Port to which the override applies, needs to be a string in the form {number}/{protocol} 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 """ return self._send_and_transform_command( Notes.create_note( text, nvt_oid, days_active=days_active, hosts=hosts, port=port, result_id=result_id, severity=severity, task_id=task_id, ) ) def modify_note( self, note_id: EntityID, text: str, *, days_active: Optional[int] = None, hosts: Optional[list[str]] = None, port: Optional[str] = None, result_id: Optional[EntityID] = None, severity: Optional[Severity] = None, task_id: Optional[EntityID] = None, ) -> T: """Modify a note Args: note_id: The UUID of the note to modify text: Text of the note days_active: Days note will be active. -1 on always, 0 off hosts: A list of host addresses port: Port to which the override applies, needs to be a string in the form {number}/{protocol} 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 """ return self._send_and_transform_command( Notes.modify_note( note_id, text, days_active=days_active, hosts=hosts, port=port, result_id=result_id, severity=severity, task_id=task_id, ) ) def clone_note(self, note_id: EntityID) -> T: """Clone an existing note Args: note_id: UUID of an existing note to clone from """ return self._send_and_transform_command(Notes.clone_note(note_id)) def delete_note( self, note_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Delete an existing note Args: note_id: UUID of the note to be deleted. ultimate: Whether to remove entirely or to the trashcan. """ return self._send_and_transform_command( Notes.delete_note(note_id, ultimate=ultimate) ) def get_notes( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, result: Optional[bool] = None, ) -> T: """Request a list of notes Args: filter_string: Filter notes by a string 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. """ return self._send_and_transform_command( Notes.get_notes( filter_string=filter_string, filter_id=filter_id, details=details, result=result, ) ) def get_note(self, note_id: EntityID) -> T: """Request a single note Arguments: note_id: UUID of an existing note """ return self._send_and_transform_command(Notes.get_note(note_id)) def create_override( self, text: str, nvt_oid: str, *, days_active: Optional[int] = None, hosts: Optional[list[str]] = None, port: Optional[str] = None, result_id: Optional[EntityID] = None, severity: Optional[Severity] = None, new_severity: Optional[Severity] = None, task_id: Optional[EntityID] = None, ) -> T: """Create a new override Args: 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, needs to be a string in the form {number}/{protocol} 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 """ return self._send_and_transform_command( Overrides.create_override( text, nvt_oid, days_active=days_active, hosts=hosts, port=port, result_id=result_id, severity=severity, new_severity=new_severity, task_id=task_id, ) ) def modify_override( self, override_id: EntityID, text: str, *, days_active: Optional[int] = None, hosts: Optional[list[str]] = None, port: Optional[str] = None, result_id: Optional[EntityID] = None, severity: Optional[Severity] = None, new_severity: Optional[Severity] = None, task_id: Optional[EntityID] = None, ) -> T: """Modify an existing override. Args: 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 the override applies, needs to be a string in the form {number}/{protocol} 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. """ return self._send_and_transform_command( Overrides.modify_override( override_id, text, days_active=days_active, hosts=hosts, port=port, result_id=result_id, severity=severity, new_severity=new_severity, task_id=task_id, ) ) def clone_override(self, override_id: EntityID) -> T: """Clone an existing override Args: override_id: UUID of an existing override to clone from """ return self._send_and_transform_command( Overrides.clone_override(override_id) ) def delete_override( self, override_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Delete an existing override Args: override_id: UUID of an existing override to delete ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Overrides.delete_override(override_id, ultimate=ultimate) ) def get_overrides( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, result: Optional[bool] = None, ) -> T: """Request a list of overrides Args: 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 """ return self._send_and_transform_command( Overrides.get_overrides( filter_string=filter_string, filter_id=filter_id, details=details, result=result, ) ) def get_override(self, override_id: EntityID) -> T: """Request a single override Args: override_id: UUID of an existing override """ return self._send_and_transform_command( Overrides.get_override(override_id) ) 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[EntityID] = None, ssh_credential_port: Optional[Union[int, str]] = None, smb_credential_id: Optional[EntityID] = None, esxi_credential_id: Optional[EntityID] = None, snmp_credential_id: Optional[EntityID] = None, alive_test: Optional[Union[str, 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[EntityID] = None, ) -> T: """Create a new target Args: 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 """ return self._send_and_transform_command( Targets.create_target( name, asset_hosts_filter=asset_hosts_filter, hosts=hosts, comment=comment, exclude_hosts=exclude_hosts, ssh_credential_id=ssh_credential_id, ssh_credential_port=ssh_credential_port, smb_credential_id=smb_credential_id, esxi_credential_id=esxi_credential_id, snmp_credential_id=snmp_credential_id, alive_test=alive_test, allow_simultaneous_ips=allow_simultaneous_ips, reverse_lookup_only=reverse_lookup_only, reverse_lookup_unify=reverse_lookup_unify, port_range=port_range, port_list_id=port_list_id, ) ) def modify_target( self, target_id: EntityID, *, name: Optional[str] = None, comment: Optional[str] = None, hosts: Optional[list[str]] = None, exclude_hosts: Optional[list[str]] = None, ssh_credential_id: Optional[EntityID] = None, ssh_credential_port: Optional[Union[str, int]] = None, smb_credential_id: Optional[EntityID] = None, esxi_credential_id: Optional[EntityID] = None, snmp_credential_id: Optional[EntityID] = None, alive_test: Optional[Union[AliveTest, str]] = None, allow_simultaneous_ips: Optional[bool] = None, reverse_lookup_only: Optional[bool] = None, reverse_lookup_unify: Optional[bool] = None, port_list_id: Optional[EntityID] = None, ) -> T: """Modify an existing target. Args: target_id: UUID 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. """ return self._send_and_transform_command( Targets.modify_target( target_id, name=name, comment=comment, hosts=hosts, exclude_hosts=exclude_hosts, ssh_credential_id=ssh_credential_id, ssh_credential_port=ssh_credential_port, smb_credential_id=smb_credential_id, esxi_credential_id=esxi_credential_id, snmp_credential_id=snmp_credential_id, alive_test=alive_test, allow_simultaneous_ips=allow_simultaneous_ips, reverse_lookup_only=reverse_lookup_only, reverse_lookup_unify=reverse_lookup_unify, port_list_id=port_list_id, ) ) def clone_target(self, target_id: EntityID) -> T: """Clone an existing target. Args: target_id: UUID of an existing target to clone. """ return self._send_and_transform_command(Targets.clone_target(target_id)) def delete_target( self, target_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Delete an existing target. Args: target_id: UUID of an existing target to delete. ultimate: Whether to remove entirely or to the trashcan. """ return self._send_and_transform_command( Targets.delete_target(target_id, ultimate=ultimate) ) def get_target( self, target_id: EntityID, *, tasks: Optional[bool] = None ) -> T: """Request a single target. Args: target_id: UUID of the target to request. tasks: Whether to include list of tasks that use the target """ return self._send_and_transform_command( Targets.get_target(target_id, tasks=tasks) ) def get_targets( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> T: """Request a list of targets. Args: filter_string: Filter term to use for the query. filter_id: UUID of an existing filter to use for the query. trash: Whether to include targets in the trashcan. tasks: Whether to include list of tasks that use the target. """ return self._send_and_transform_command( Targets.get_targets( filter_string=filter_string, filter_id=filter_id, trash=trash, tasks=tasks, ) ) def create_alert( self, name: str, condition: AlertCondition, event: AlertEvent, method: AlertMethod, *, method_data: Optional[dict[str, str]] = None, event_data: Optional[dict[str, str]] = None, condition_data: Optional[dict[str, str]] = None, filter_id: Optional[EntityID] = None, comment: Optional[str] = None, ) -> T: """Create a new alert Args: 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 """ return self._send_and_transform_command( Alerts.create_alert( name, condition, event, method, method_data=method_data, event_data=event_data, condition_data=condition_data, filter_id=filter_id, comment=comment, ) ) def modify_alert( self, alert_id: EntityID, *, name: Optional[str] = None, comment: Optional[str] = None, filter_id: Optional[EntityID] = None, event: Optional[Union[AlertEvent, str]] = None, event_data: Optional[dict] = None, condition: Optional[Union[AlertCondition, str]] = None, condition_data: Optional[dict[str, str]] = None, method: Optional[Union[AlertMethod, str]] = None, method_data: Optional[dict[str, str]] = None, ) -> T: """Modify an existing alert. Args: 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 """ return self._send_and_transform_command( Alerts.modify_alert( alert_id, name=name, comment=comment, filter_id=filter_id, event=event, event_data=event_data, condition=condition, condition_data=condition_data, method=method, method_data=method_data, ) ) def clone_alert(self, alert_id: EntityID) -> T: """Clone an existing alert Args: alert_id: UUID of the alert to clone from """ return self._send_and_transform_command(Alerts.clone_alert(alert_id)) def delete_alert( self, alert_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Delete an existing alert Args: alert_id: UUID of the alert to delete ultimate: Whether to remove entirely or to the trashcan. """ return self._send_and_transform_command( Alerts.delete_alert(alert_id, ultimate=ultimate) ) def test_alert(self, alert_id: EntityID) -> T: """Run an alert Invoke a test run of an alert Args: alert_id: UUID of the alert to be tested """ return self._send_and_transform_command(Alerts.test_alert(alert_id)) def trigger_alert( self, alert_id: EntityID, report_id: EntityID, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, report_format_id: Optional[Union[EntityID, ReportFormatType]] = None, delta_report_id: Optional[EntityID] = None, ) -> T: """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. Args: 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. """ return self._send_and_transform_command( Alerts.trigger_alert( alert_id, report_id, filter_string=filter_string, filter_id=filter_id, report_format_id=report_format_id, delta_report_id=delta_report_id, ) ) def get_alerts( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> T: """Request a list of alerts Args: 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 """ return self._send_and_transform_command( Alerts.get_alerts( filter_string=filter_string, filter_id=filter_id, trash=trash, tasks=tasks, ) ) def get_alert( self, alert_id: EntityID, *, tasks: Optional[bool] = None ) -> T: """Request a single alert Arguments: alert_id: UUID of an existing alert tasks: Whether to include the tasks using the alert """ return self._send_and_transform_command( Alerts.get_alert(alert_id, tasks=tasks) ) def create_audit( self, name: str, policy_id: EntityID, target_id: EntityID, scanner_id: EntityID, *, alterable: Optional[bool] = None, hosts_ordering: Optional[Union[HostsOrdering, str]] = None, schedule_id: Optional[str] = None, alert_ids: Optional[list[EntityID]] = None, comment: Optional[str] = None, schedule_periods: Optional[int] = None, observers: Optional[list[EntityID]] = None, preferences: Optional[dict[str, str]] = None, ) -> T: """Create a new audit Args: 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. """ return self._send_and_transform_command( Audits.create_audit( name, policy_id, target_id, scanner_id, alterable=alterable, hosts_ordering=hosts_ordering, schedule_id=schedule_id, alert_ids=alert_ids, comment=comment, schedule_periods=schedule_periods, observers=observers, preferences=preferences, ) ) def modify_audit( self, audit_id: EntityID, *, name: Optional[str] = None, policy_id: Optional[EntityID] = None, target_id: Optional[EntityID] = None, scanner_id: Optional[EntityID] = None, alterable: Optional[bool] = None, hosts_ordering: Optional[Union[str, HostsOrdering]] = None, schedule_id: Optional[EntityID] = None, schedule_periods: Optional[int] = None, comment: Optional[str] = None, alert_ids: Optional[list[EntityID]] = None, observers: Optional[list[EntityID]] = None, preferences: Optional[dict[str, str]] = None, ) -> T: """Modifies an existing audit. Args: 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. """ return self._send_and_transform_command( Audits.modify_audit( audit_id, name=name, policy_id=policy_id, target_id=target_id, scanner_id=scanner_id, alterable=alterable, hosts_ordering=hosts_ordering, schedule_id=schedule_id, alert_ids=alert_ids, comment=comment, schedule_periods=schedule_periods, observers=observers, preferences=preferences, ) ) def clone_audit(self, audit_id: EntityID) -> T: """Clone an existing audit Args: audit_id: UUID of the audit to clone """ return self._send_and_transform_command(Audits.clone_audit(audit_id)) def delete_audit( self, audit_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Delete an existing audit Args: audit_id: UUID of the audit to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Audits.delete_audit(audit_id, ultimate=ultimate) ) def get_audits( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, details: Optional[bool] = None, schedules_only: Optional[bool] = None, ) -> T: """Request a list of audits Args: 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 """ return self._send_and_transform_command( Audits.get_audits( filter_string=filter_string, filter_id=filter_id, trash=trash, details=details, schedules_only=schedules_only, ) ) def get_audit(self, audit_id: EntityID) -> T: """Request a single audit Args: audit_id: UUID of an existing audit """ return self._send_and_transform_command(Audits.get_audit(audit_id)) def resume_audit(self, audit_id: EntityID) -> T: """Resume an existing stopped audit Args: audit_id: UUID of the audit to be resumed """ return self._send_and_transform_command(Audits.resume_audit(audit_id)) def start_audit(self, audit_id: EntityID) -> T: """Start an existing audit Args: audit_id: UUID of the audit to be started """ return self._send_and_transform_command(Audits.start_audit(audit_id)) def stop_audit(self, audit_id: EntityID) -> T: """Stop an existing running audit Args: audit_id: UUID of the audit to be stopped """ return self._send_and_transform_command(Audits.stop_audit(audit_id)) def clone_credential(self, credential_id: EntityID) -> T: """Clone an existing credential Args: credential_id: UUID of the credential to clone """ return self._send_and_transform_command( Credentials.clone_credential(credential_id) ) def create_credential( self, name: str, credential_type: Union[CredentialType, str], *, 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[Union[SnmpAuthAlgorithm, str]] = None, community: Optional[str] = None, privacy_algorithm: Optional[Union[SnmpPrivacyAlgorithm, str]] = None, privacy_password: Optional[str] = None, public_key: Optional[str] = None, ) -> T: """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 Args: 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', ) """ return self._send_and_transform_command( Credentials.create_credential( name, credential_type, comment=comment, allow_insecure=allow_insecure, certificate=certificate, key_phrase=key_phrase, private_key=private_key, login=login, password=password, auth_algorithm=auth_algorithm, community=community, privacy_algorithm=privacy_algorithm, privacy_password=privacy_password, public_key=public_key, ) ) def delete_credential( self, credential_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Delete an existing credential Args: credential_id: UUID of the credential to delete ultimate: Whether to remove entirely or to the trashcan. """ return self._send_and_transform_command( Credentials.delete_credential(credential_id, ultimate=ultimate) ) 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, ) -> T: """Request a list of credentials Args: 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 """ return self._send_and_transform_command( Credentials.get_credentials( filter_string=filter_string, filter_id=filter_id, scanners=scanners, trash=trash, targets=targets, ) ) def get_credential( self, credential_id: str, *, scanners: Optional[bool] = None, targets: Optional[bool] = None, credential_format: Optional[Union[CredentialFormat, str]] = None, ) -> T: """Request a single credential Args: 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" """ return self._send_and_transform_command( Credentials.get_credential( credential_id, scanners=scanners, targets=targets, credential_format=credential_format, ) ) 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[Union[SnmpAuthAlgorithm, str]] = None, community: Optional[str] = None, privacy_algorithm: Optional[Union[SnmpPrivacyAlgorithm, str]] = None, privacy_password: Optional[str] = None, public_key: Optional[str] = None, ) -> T: """Modifies an existing credential. Args: 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 """ return self._send_and_transform_command( Credentials.modify_credential( credential_id, name=name, comment=comment, allow_insecure=allow_insecure, certificate=certificate, key_phrase=key_phrase, private_key=private_key, login=login, password=password, auth_algorithm=auth_algorithm, community=community, privacy_algorithm=privacy_algorithm, privacy_password=privacy_password, public_key=public_key, ) ) def clone_filter(self, filter_id: EntityID) -> T: """Clone a filter Args: filter_id: ID of the filter to clone """ return self._send_and_transform_command(Filters.clone_filter(filter_id)) def create_filter( self, name: str, *, filter_type: Optional[FilterType] = None, comment: Optional[str] = None, term: Optional[str] = None, ) -> T: """Create a new filter Args: name: Name of the new filter filter_type: Filter for entity type comment: Comment for the filter term: Filter term e.g. 'name=foo' """ return self._send_and_transform_command( Filters.create_filter( name, filter_type=filter_type, comment=comment, term=term ) ) def delete_filter( self, filter_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing filter Args: filter_id: UUID of the filter to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Filters.delete_filter(filter_id, ultimate=ultimate) ) def get_filters( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, alerts: Optional[bool] = None, ) -> T: """Request a list of filters Args: 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. """ return self._send_and_transform_command( Filters.get_filters( filter_string=filter_string, filter_id=filter_id, trash=trash, alerts=alerts, ) ) def get_filter( self, filter_id: EntityID, *, alerts: Optional[bool] = None ) -> T: """Request a single filter Args: filter_id: UUID of an existing filter alerts: Whether to include list of alerts that use the filter. """ return self._send_and_transform_command( Filters.get_filter(filter_id, alerts=alerts) ) def modify_filter( self, filter_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, term: Optional[str] = None, filter_type: Optional[FilterType] = None, ) -> T: """Modifies an existing filter. Args: 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. """ return self._send_and_transform_command( Filters.modify_filter( filter_id, comment=comment, name=name, term=term, filter_type=filter_type, ) ) def clone_group(self, group_id: EntityID) -> T: """Clone an existing group Args: group_id: UUID of an existing group to clone from """ return self._send_and_transform_command(Groups.clone_group(group_id)) def create_group( self, name: str, *, comment: Optional[str] = None, special: Optional[bool] = False, users: Optional[list[str]] = None, ) -> T: """Create a new group Args: 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 """ return self._send_and_transform_command( Groups.create_group( name, comment=comment, special=special, users=users ) ) def delete_group( self, group_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing group Args: group_id: UUID of the group to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Groups.delete_group(group_id, ultimate=ultimate) ) def get_groups( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, ) -> T: """Request a list of groups Args: 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 """ return self._send_and_transform_command( Groups.get_groups( filter_string=filter_string, filter_id=filter_id, trash=trash ) ) def get_group(self, group_id: EntityID) -> T: """Request a single group Args: group_id: UUID of an existing group """ return self._send_and_transform_command(Groups.get_group(group_id)) def modify_group( self, group_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, users: Optional[list[str]] = None, ) -> T: """Modifies an existing group. Args: 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 """ return self._send_and_transform_command( Groups.modify_group( group_id, comment=comment, name=name, users=users ) ) def create_host(self, name: str, *, comment: Optional[str] = None) -> T: """Create a new host host Args: name: Name for the new host host comment: Comment for the new host host """ return self._send_and_transform_command( Hosts.create_host(name, comment=comment) ) def delete_host(self, host_id: EntityID) -> T: """Deletes an existing host Args: host_id: UUID of the single host to delete. """ return self._send_and_transform_command(Hosts.delete_host(host_id)) def get_hosts( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, ) -> T: """Request a list of hosts Args: 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 additional information (e.g. tags) """ return self._send_and_transform_command( Hosts.get_hosts( filter_string=filter_string, filter_id=filter_id, details=details, ) ) def get_host( self, host_id: EntityID, *, details: Optional[bool] = None ) -> T: """Request a single host Arguments: host_id: UUID of an existing host details: Whether to include additional information (e.g. tags) """ return self._send_and_transform_command( Hosts.get_host(host_id, details=details) ) def modify_host( self, host_id: EntityID, *, comment: Optional[str] = None ) -> T: """Modifies an existing host. Args: 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. """ return self._send_and_transform_command( Hosts.modify_host(host_id, comment=comment) ) def delete_operating_system( self, operating_system_id: EntityID, ) -> T: """Deletes an existing operating system Args: operating_system_id: UUID of the single operating_system to delete. """ return self._send_and_transform_command( OperatingSystems.delete_operating_system(operating_system_id) ) def get_operating_systems( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, ) -> T: """Request a list of operating systems Args: 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 additional information (e.g. tags) """ return self._send_and_transform_command( OperatingSystems.get_operating_systems( filter_string=filter_string, filter_id=filter_id, details=details, ) ) def get_operating_system( self, operating_system_id: EntityID, *, details: Optional[bool] = None ) -> T: """Request a single operating system Args: operating_system_id: UUID of an existing operating_system details: Whether to include additional information (e.g. tags) """ return self._send_and_transform_command( OperatingSystems.get_operating_system( operating_system_id, details=details ) ) def modify_operating_system( self, operating_system_id: EntityID, *, comment: Optional[str] = None ) -> T: """Modifies an existing operating system. Args: 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. """ return self._send_and_transform_command( OperatingSystems.modify_operating_system( operating_system_id, comment=comment ) ) def clone_permission(self, permission_id: EntityID) -> T: """Clone an existing permission Args: permission_id: UUID of an existing permission to clone from """ return self._send_and_transform_command( Permissions.clone_permission(permission_id) ) def create_permission( self, name: str, subject_id: EntityID, subject_type: Union[PermissionSubjectType, str], *, resource_id: Optional[str] = None, resource_type: Optional[Union[EntityType, str]] = None, comment: Optional[str] = None, ) -> T: """Create a new permission Args: 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 """ return self._send_and_transform_command( Permissions.create_permission( name, subject_id, subject_type, resource_id=resource_id, resource_type=resource_type, comment=comment, ) ) def delete_permission( self, permission_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing permission Args: permission_id: UUID of the permission to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Permissions.delete_permission(permission_id, ultimate=ultimate) ) def get_permissions( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, ) -> T: """Request a list of permissions Args: 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 """ return self._send_and_transform_command( Permissions.get_permissions( filter_string=filter_string, filter_id=filter_id, trash=trash ) ) def get_permission(self, permission_id: EntityID) -> T: """Request a single permission Args: permission_id: UUID of an existing permission """ return self._send_and_transform_command( Permissions.get_permission(permission_id) ) def modify_permission( self, permission_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, resource_id: Optional[EntityID] = None, resource_type: Optional[Union[EntityType, str]] = None, subject_id: Optional[EntityID] = None, subject_type: Optional[Union[PermissionSubjectType, str]] = None, ) -> T: """Modifies an existing permission. Args: 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 """ return self._send_and_transform_command( Permissions.modify_permission( permission_id, comment=comment, name=name, resource_id=resource_id, resource_type=resource_type, subject_id=subject_id, subject_type=subject_type, ) ) def clone_policy(self, policy_id: EntityID) -> T: """Clone a policy from an existing one Args: policy_id: UUID of the existing policy """ return self._send_and_transform_command( Policies.clone_policy(policy_id) ) def create_policy( self, name: str, *, policy_id: Optional[EntityID] = None, comment: Optional[str] = None, ) -> T: """Create a new policy Args: 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 """ return self._send_and_transform_command( Policies.create_policy(name, policy_id=policy_id, comment=comment) ) def delete_policy( self, policy_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing policy Args: policy_id: UUID of the policy to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Policies.delete_policy(policy_id, ultimate=ultimate) ) def get_policies( self, *, audits: Optional[bool] = None, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, families: Optional[bool] = None, preferences: Optional[bool] = None, trash: Optional[bool] = None, ) -> T: """Request a list of policies Args: 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 """ return self._send_and_transform_command( Policies.get_policies( audits=audits, filter_string=filter_string, filter_id=filter_id, details=details, families=families, preferences=preferences, trash=trash, ) ) def get_policy( self, policy_id: EntityID, *, audits: Optional[bool] = None ) -> T: """Request a single policy Args: policy_id: UUID of an existing policy audits: Whether to get audits using this policy """ return self._send_and_transform_command( Policies.get_policy(policy_id, audits=audits) ) def import_policy(self, policy: str) -> T: """Import a policy from XML Args: policy: Policy XML as string to import. This XML must contain a :code:`` root element. """ return self._send_and_transform_command(Policies.import_policy(policy)) def modify_policy_set_nvt_preference( self, policy_id: EntityID, name: str, nvt_oid: str, *, value: Optional[str] = None, ) -> T: """Modifies the nvt preferences of an existing policy. Args: 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. """ return self._send_and_transform_command( Policies.modify_policy_set_nvt_preference( policy_id, name, nvt_oid, value=value ) ) def modify_policy_set_name(self, policy_id: EntityID, name: str) -> T: """Modifies the name of an existing policy Args: policy_id: UUID of policy to modify. name: New name for the policy. """ return self._send_and_transform_command( Policies.modify_policy_set_name(policy_id, name) ) def modify_policy_set_comment( self, policy_id: EntityID, comment: Optional[str] = None ) -> T: """Modifies the comment of an existing policy Args: 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. """ return self._send_and_transform_command( Policies.modify_policy_set_comment(policy_id, comment=comment) ) def modify_policy_set_scanner_preference( self, policy_id: EntityID, name: str, *, value: Optional[str] = None ) -> T: """Modifies the scanner preferences of an existing policy Args: 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. """ return self._send_and_transform_command( Policies.modify_policy_set_scanner_preference( policy_id, name, value=value ) ) def modify_policy_set_nvt_selection( self, policy_id: EntityID, family: str, nvt_oids: Sequence[str] ) -> T: """Modifies the selected nvts of an existing policy The manager updates the given family in the policy to include only the given NVTs. Args: 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. """ return self._send_and_transform_command( Policies.modify_policy_set_nvt_selection( policy_id, family, nvt_oids ) ) def modify_policy_set_family_selection( self, policy_id: EntityID, families: Sequence[tuple[str, bool, bool]], *, auto_add_new_families: Optional[bool] = True, ) -> T: """ Selected the NVTs of a policy at a family level. Args: 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. """ return self._send_and_transform_command( Policies.modify_policy_set_family_selection( policy_id, families, auto_add_new_families=auto_add_new_families ) ) def delete_report(self, report_id: EntityID) -> T: """Deletes an existing report Args: report_id: UUID of the report to be deleted. """ return self._send_and_transform_command( Reports.delete_report(report_id) ) def get_report( self, report_id: EntityID, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, delta_report_id: Optional[EntityID] = None, report_format_id: Optional[Union[str, ReportFormatType]] = None, ignore_pagination: Optional[bool] = None, details: Optional[bool] = True, ) -> T: """Request a single report Args: 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 """ return self._send_and_transform_command( Reports.get_report( report_id, filter_string=filter_string, filter_id=filter_id, delta_report_id=delta_report_id, report_format_id=report_format_id, ignore_pagination=ignore_pagination, details=details, ) ) def get_reports( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, note_details: Optional[bool] = None, override_details: Optional[bool] = None, ignore_pagination: Optional[bool] = None, details: Optional[bool] = None, ) -> T: """Request a list of reports Args: 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 ignore_pagination: Whether to ignore the filter terms "first" and "rows". details: Whether to exclude results """ return self._send_and_transform_command( Reports.get_reports( filter_string=filter_string, filter_id=filter_id, note_details=note_details, override_details=override_details, ignore_pagination=ignore_pagination, details=details, ) ) def import_report( self, report: str, task_id: EntityID, *, in_assets: Optional[bool] = None, ) -> T: """Import a Report from XML Args: 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 """ return self._send_and_transform_command( Reports.import_report(report, task_id, in_assets=in_assets) ) def get_result(self, result_id: EntityID) -> T: """Request a single result Args: result_id: UUID of an existing result """ return self._send_and_transform_command(Results.get_result(result_id)) 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, ) -> T: """Request a list of results Args: 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 """ return self._send_and_transform_command( Results.get_results( filter_string=filter_string, filter_id=filter_id, task_id=task_id, note_details=note_details, override_details=override_details, details=details, ) ) def clone_role(self, role_id: EntityID) -> T: """Clone an existing role Args: role_id: UUID of an existing role to clone from """ return self._send_and_transform_command(Roles.clone_role(role_id)) def create_role( self, name: str, *, comment: Optional[str] = None, users: Optional[list[str]] = None, ) -> T: """Create a new role Args: name: Name of the role comment: Comment for the role users: List of user names to add to the role """ return self._send_and_transform_command( Roles.create_role(name, comment=comment, users=users) ) def delete_role( self, role_id: str, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing role Args: role_id: UUID of the role to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Roles.delete_role(role_id, ultimate=ultimate) ) def get_roles( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, ) -> T: """Request a list of roles Args: 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 """ return self._send_and_transform_command( Roles.get_roles( filter_string=filter_string, filter_id=filter_id, trash=trash ) ) def get_role(self, role_id: EntityID) -> T: """Request a single role Args: role_id: UUID of an existing role """ return self._send_and_transform_command(Roles.get_role(role_id)) def modify_role( self, role_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, users: Optional[list[str]] = None, ) -> T: """Modifies an existing role. Args: role_id: UUID of role to modify. comment: Name of role. name: Comment on role. users: List of user names. """ return self._send_and_transform_command( Roles.modify_role(role_id, comment=comment, name=name, users=users) ) def clone_schedule(self, schedule_id: EntityID) -> T: """Clone an existing schedule Args: schedule_id: UUID of an existing schedule to clone from """ return self._send_and_transform_command( Schedules.clone_schedule(schedule_id) ) def create_schedule( self, name: str, icalendar: str, timezone: str, *, comment: Optional[str] = None, ) -> T: """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' ) Args: name: Name of the new schedule icalendar: `iCalendar`_ (RFC 5545) based data. timezone: Timezone to use for the icalendar 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. .. _iCalendar: https://tools.ietf.org/html/rfc5545 """ return self._send_and_transform_command( Schedules.create_schedule( name, icalendar, timezone, comment=comment ) ) def delete_schedule( self, schedule_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing schedule Args: schedule_id: UUID of the schedule to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Schedules.delete_schedule(schedule_id, ultimate=ultimate) ) def get_schedules( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> T: """Request a list of schedules Args: 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 """ return self._send_and_transform_command( Schedules.get_schedules( filter_string=filter_string, filter_id=filter_id, trash=trash, tasks=tasks, ) ) def get_schedule( self, schedule_id: EntityID, *, tasks: Optional[bool] = None ) -> T: """Request a single schedule Args: schedule_id: UUID of an existing schedule tasks: Whether to include tasks using the schedules """ return self._send_and_transform_command( Schedules.get_schedule(schedule_id, tasks=tasks) ) def modify_schedule( self, schedule_id: EntityID, *, name: Optional[str] = None, icalendar: Optional[str] = None, timezone: Optional[str] = None, comment: Optional[str] = None, ) -> T: """Modifies an existing schedule Args: 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 icalendar 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. .. _iCalendar: https://tools.ietf.org/html/rfc5545 """ return self._send_and_transform_command( Schedules.modify_schedule( schedule_id, name=name, icalendar=icalendar, timezone=timezone, comment=comment, ) ) def get_nvt_families(self, *, sort_order: Optional[str] = None) -> T: """Request a list of nvt families Args: sort_order: Sort order """ return self._send_and_transform_command( Nvts.get_nvt_families(sort_order=sort_order) ) 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[EntityID] = None, preferences_config_id: Optional[EntityID] = None, family: Optional[str] = None, sort_order: Optional[str] = None, sort_field: Optional[str] = None, ) -> T: """Request a list of nvts Args: 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 """ return self._send_and_transform_command( Nvts.get_scan_config_nvts( details=details, preferences=preferences, preference_count=preference_count, timeout=timeout, config_id=config_id, preferences_config_id=preferences_config_id, family=family, sort_order=sort_order, sort_field=sort_field, ) ) def get_scan_config_nvt(self, nvt_oid: str) -> T: """Request a single nvt Args: nvt_oid: OID of an existing nvt """ return self._send_and_transform_command( Nvts.get_scan_config_nvt(nvt_oid) ) def get_nvts( self, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, extended: 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, ) -> T: """Request a list of NVTs Args: 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 extended: Whether to receive extended NVT information (calls get_nvts, instead of get_info) preferences: Whether to include NVT preferences (only for extended) preference_count: Whether to include preference count (only for extended) timeout: Whether to include the special timeout preference (only for extended) config_id: UUID of scan config to which to limit the NVT listing (only for extended) preferences_config_id: UUID of scan config to use for preference values (only for extended) family: Family to which to limit NVT listing (only for extended) sort_order: Sort order (only for extended) sort_field: Sort field (only for extended) """ return self._send_and_transform_command( Nvts.get_nvts( filter_string=filter_string, filter_id=filter_id, name=name, details=details, extended=extended, preferences=preferences, preference_count=preference_count, timeout=timeout, config_id=config_id, preferences_config_id=preferences_config_id, family=family, sort_order=sort_order, sort_field=sort_field, ) ) def get_nvt(self, nvt_id: str, *, extended: Optional[bool] = None) -> T: """Request a single NVT Args: nvt_id: ID of an existing NVT extended: Whether to receive extended NVT information (calls get_nvts, instead of get_info) """ return self._send_and_transform_command( Nvts.get_nvt(nvt_id, extended=extended) ) def get_nvt_preferences( self, *, nvt_oid: Optional[str] = None, ) -> T: """Request a list of preferences The preference element includes just the name and value, with the NVT and type built into the name. Args: nvt_oid: OID of nvt """ return self._send_and_transform_command( Nvts.get_nvt_preferences(nvt_oid=nvt_oid) ) def get_nvt_preference( self, name: str, *, nvt_oid: Optional[str] = None, ) -> T: """Request a nvt preference Args: name: name of a particular preference nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values """ return self._send_and_transform_command( Nvts.get_nvt_preference(name, nvt_oid=nvt_oid) ) def get_info(self, info_id: EntityID, info_type: InfoType) -> T: """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 """ return self._send_and_transform_command( SecInfo.get_info(info_id, info_type) ) 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, ) -> T: """Request a list of security information Args: info_type: Type must be either CERT_BUND_ADV, CPE, CVE, DFN_CERT_ADV, OVALDEF or NVT 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 """ return self._send_and_transform_command( SecInfo.get_info_list( info_type, filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) ) def get_cves( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> T: """Request a list of CVEs Args: 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 """ return self._send_and_transform_command( Cves.get_cves( filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) ) def get_cve(self, cve_id: str) -> T: """Request a single CVE Args: cve_id: ID of an existing CVE """ return self._send_and_transform_command(Cves.get_cve(cve_id)) def get_cpes( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> T: """Request a list of CPEs Args: 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 """ return self._send_and_transform_command( Cpes.get_cpes( filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) ) def get_cpe(self, cpe_id: str) -> T: """Request a single CPE Args: cpe_id: ID of an existing CPE """ return self._send_and_transform_command(Cpes.get_cpe(cpe_id)) def get_dfn_cert_advisories( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> T: """Request a list of DFN-CERT Advisories Args: 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 """ return self._send_and_transform_command( DfnCertAdvisories.get_dfn_cert_advisories( filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) ) def get_dfn_cert_advisory(self, cert_id: EntityID) -> T: """Request a single DFN-CERT Advisory Args: cert_id: ID of an existing DFN-CERT Advisory """ return self._send_and_transform_command( DfnCertAdvisories.get_dfn_cert_advisory(cert_id) ) def get_cert_bund_advisories( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> T: """Request a list of CERT-BUND Advisories Args: 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 """ return self._send_and_transform_command( CertBundAdvisories.get_cert_bund_advisories( filter_string=filter_string, filter_id=filter_id, name=name, details=details, ) ) def get_cert_bund_advisory(self, cert_id: EntityID) -> T: """Request a single CERT-BUND Advisory Args: cert_id: ID of an existing CERT-BUND Advisory """ return self._send_and_transform_command( CertBundAdvisories.get_cert_bund_advisory(cert_id) ) def clone_tag(self, tag_id: EntityID) -> T: """Clone an existing tag Args: tag_id: UUID of an existing tag to clone from """ return self._send_and_transform_command(Tags.clone_tag(tag_id)) def create_tag( self, name: str, resource_type: EntityType, *, resource_filter: Optional[str] = None, resource_ids: Optional[list[EntityID]] = None, value: Optional[str] = None, comment: Optional[str] = None, active: Optional[bool] = None, ) -> T: """Create a tag Args: 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. """ return self._send_and_transform_command( Tags.create_tag( name, resource_type, resource_filter=resource_filter, resource_ids=resource_ids, value=value, comment=comment, active=active, ) ) def delete_tag( self, tag_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing tag Args: tag_id: UUID of the tag to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Tags.delete_tag(tag_id, ultimate=ultimate) ) def get_tags( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, names_only: Optional[bool] = None, ) -> T: """Request a list of tags Args: 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 """ return self._send_and_transform_command( Tags.get_tags( filter_string=filter_string, filter_id=filter_id, trash=trash, names_only=names_only, ) ) def get_tag(self, tag_id: EntityID) -> T: """Request a single tag Args: tag_id: UUID of an existing tag """ return self._send_and_transform_command(Tags.get_tag(tag_id)) def modify_tag( self, tag_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, value: Optional[str] = None, active: Optional[bool] = None, resource_action: Optional[str] = None, resource_type: Optional[EntityType] = None, resource_filter: Optional[str] = None, resource_ids: Optional[list[EntityID]] = None, ) -> T: """Modifies an existing tag. Args: 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. """ return self._send_and_transform_command( Tags.modify_tag( tag_id, comment=comment, name=name, value=value, active=active, resource_action=resource_action, resource_type=resource_type, resource_filter=resource_filter, resource_ids=resource_ids, ) ) def clone_task(self, task_id: EntityID) -> T: """Clone an existing task Args: task_id: UUID of existing task to clone from """ return self._send_and_transform_command(Tasks.clone_task(task_id)) def create_container_task( self, name: str, *, comment: Optional[str] = None ) -> T: """Create a new container task A container task is a "meta" task to import and view reports from other systems. Args: name: Name of the task comment: Comment for the task """ return self._send_and_transform_command( Tasks.create_container_task(name, comment=comment) ) def create_task( self, name: str, config_id: EntityID, target_id: EntityID, scanner_id: EntityID, *, alterable: Optional[bool] = None, hosts_ordering: Optional[HostsOrdering] = None, schedule_id: Optional[EntityID] = None, alert_ids: Optional[Sequence[EntityID]] = None, comment: Optional[str] = None, schedule_periods: Optional[int] = None, observers: Optional[Sequence[str]] = None, preferences: Optional[Mapping[str, SupportsStr]] = None, ) -> T: """Create a new scan task Args: 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. """ return self._send_and_transform_command( Tasks.create_task( name, config_id, target_id, scanner_id, alterable=alterable, hosts_ordering=hosts_ordering, schedule_id=schedule_id, alert_ids=alert_ids, comment=comment, schedule_periods=schedule_periods, observers=observers, preferences=preferences, ) ) def delete_task( self, task_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing task Args: task_id: UUID of the task to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Tasks.delete_task(task_id, ultimate=ultimate) ) def get_tasks( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, details: Optional[bool] = None, schedules_only: Optional[bool] = None, ignore_pagination: Optional[bool] = None, ) -> T: """Request a list of tasks Args: 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 ignore_pagination: Whether to ignore pagination settings (filter terms "first" and "rows"). Default is False. """ return self._send_and_transform_command( Tasks.get_tasks( filter_string=filter_string, filter_id=filter_id, trash=trash, details=details, schedules_only=schedules_only, ignore_pagination=ignore_pagination, ) ) def get_task(self, task_id: EntityID) -> T: """Request a single task Args: task_id: UUID of an existing task """ return self._send_and_transform_command(Tasks.get_task(task_id)) def modify_task( self, task_id: EntityID, *, name: Optional[str] = None, config_id: Optional[EntityID] = None, target_id: Optional[EntityID] = None, scanner_id: Optional[EntityID] = None, alterable: Optional[bool] = None, hosts_ordering: Optional[HostsOrdering] = None, schedule_id: Optional[EntityID] = None, schedule_periods: Optional[int] = None, comment: Optional[str] = None, alert_ids: Optional[Sequence[EntityID]] = None, observers: Optional[Sequence[str]] = None, preferences: Optional[Mapping[str, SupportsStr]] = None, ) -> T: """Modifies an existing task. Args: 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. """ return self._send_and_transform_command( Tasks.modify_task( task_id, name=name, config_id=config_id, target_id=target_id, scanner_id=scanner_id, alterable=alterable, hosts_ordering=hosts_ordering, schedule_id=schedule_id, schedule_periods=schedule_periods, comment=comment, alert_ids=alert_ids, observers=observers, preferences=preferences, ) ) def move_task( self, task_id: EntityID, *, slave_id: Optional[EntityID] = None ) -> T: """Move an existing task to another GMP slave scanner or the master Args: task_id: UUID of the task to be moved slave_id: UUID of the sensor to reassign the task to, empty for master. """ return self._send_and_transform_command( Tasks.move_task(task_id, slave_id=slave_id) ) def start_task(self, task_id: EntityID) -> T: """Start an existing task Args: task_id: UUID of the task to be started """ return self._send_and_transform_command(Tasks.start_task(task_id)) def resume_task(self, task_id: EntityID) -> T: """Resume an existing stopped task Args: task_id: UUID of the task to be resumed """ return self._send_and_transform_command(Tasks.resume_task(task_id)) def stop_task(self, task_id: EntityID) -> T: """Stop an existing running task Args: task_id: UUID of the task to be stopped """ return self._send_and_transform_command(Tasks.stop_task(task_id)) def clone_ticket(self, ticket_id: EntityID) -> T: """Clone an existing ticket Args: ticket_id: UUID of an existing ticket to clone from """ return self._send_and_transform_command(Tickets.clone_ticket(ticket_id)) def create_ticket( self, *, result_id: EntityID, assigned_to_user_id: EntityID, note: str, comment: Optional[str] = None, ) -> T: """Create a new ticket Args: 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 """ return self._send_and_transform_command( Tickets.create_ticket( result_id=result_id, assigned_to_user_id=assigned_to_user_id, note=note, comment=comment, ) ) def delete_ticket( self, ticket_id: EntityID, *, ultimate: Optional[bool] = False ) -> T: """Deletes an existing ticket Args: ticket_id: UUID of the ticket to be deleted. ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( Tickets.delete_ticket(ticket_id, ultimate=ultimate) ) def get_tickets( self, *, trash: Optional[bool] = None, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, ) -> T: """Request a list of tickets Args: 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 """ return self._send_and_transform_command( Tickets.get_tickets( filter_string=filter_string, filter_id=filter_id, trash=trash ) ) def get_ticket(self, ticket_id: EntityID) -> T: """Request a single ticket Args: ticket_id: UUID of an existing ticket """ return self._send_and_transform_command(Tickets.get_ticket(ticket_id)) def modify_ticket( self, ticket_id: EntityID, *, status: Optional[Union[TicketStatus, str]] = None, note: Optional[str] = None, assigned_to_user_id: Optional[EntityID] = None, comment: Optional[str] = None, ) -> T: """Modify a single ticket Args: 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 """ return self._send_and_transform_command( Tickets.modify_ticket( ticket_id, status=status, note=note, assigned_to_user_id=assigned_to_user_id, comment=comment, ) ) def clone_tls_certificate(self, tls_certificate_id: EntityID) -> T: """Modifies an existing TLS certificate. Args: tls_certificate_id: The UUID of an existing TLS certificate """ return self._send_and_transform_command( TLSCertificates.clone_tls_certificate(tls_certificate_id) ) def create_tls_certificate( self, name: str, certificate: str, *, comment: Optional[str] = None, trust: Optional[bool] = None, ) -> T: """Create a new TLS certificate Args: 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. """ return self._send_and_transform_command( TLSCertificates.create_tls_certificate( name, certificate, comment=comment, trust=trust ) ) def delete_tls_certificate(self, tls_certificate_id: EntityID) -> T: """Deletes an existing tls certificate Args: tls_certificate_id: UUID of the tls certificate to be deleted. """ return self._send_and_transform_command( TLSCertificates.delete_tls_certificate(tls_certificate_id) ) def get_tls_certificates( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, include_certificate_data: Optional[bool] = None, details: Optional[bool] = None, ) -> T: """Request a list of TLS certificates Args: 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 """ return self._send_and_transform_command( TLSCertificates.get_tls_certificates( filter_string=filter_string, filter_id=filter_id, include_certificate_data=include_certificate_data, details=details, ) ) def get_tls_certificate(self, tls_certificate_id: EntityID) -> T: """Request a single TLS certificate Args: tls_certificate_id: UUID of an existing TLS certificate """ return self._send_and_transform_command( TLSCertificates.get_tls_certificate(tls_certificate_id) ) def modify_tls_certificate( self, tls_certificate_id: EntityID, *, name: Optional[str] = None, comment: Optional[str] = None, trust: Optional[bool] = None, ) -> T: """Modifies an existing TLS certificate. Args: 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. """ return self._send_and_transform_command( TLSCertificates.modify_tls_certificate( tls_certificate_id, name=name, comment=comment, trust=trust ) ) def get_vulnerabilities( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, ) -> T: """Request a list of vulnerabilities Args: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query """ return self._send_and_transform_command( Vulnerabilities.get_vulnerabilities( filter_string=filter_string, filter_id=filter_id ) ) def get_vulnerability(self, vulnerability_id: EntityID) -> T: """Request a single vulnerability Args: vulnerability_id: ID of an existing vulnerability """ return self._send_and_transform_command( Vulnerabilities.get_vulnerability(vulnerability_id) ) def clone_report_format( self, report_format_id: Union[EntityID, ReportFormatType] ) -> T: """Clone a report format from an existing one Args: report_format_id: UUID of the existing report format or ReportFormatType (enum) """ return self._send_and_transform_command( ReportFormats.clone_report_format(report_format_id) ) def delete_report_format( self, report_format_id: Union[EntityID, ReportFormatType], *, ultimate: Optional[bool] = False, ) -> T: """Deletes an existing report format Args: report_format_id: UUID of the report format to be deleted. or ReportFormatType (enum) ultimate: Whether to remove entirely, or to the trashcan. """ return self._send_and_transform_command( ReportFormats.delete_report_format( report_format_id, ultimate=ultimate ) ) def get_report_formats( self, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, alerts: Optional[bool] = None, params: Optional[bool] = None, details: Optional[bool] = None, ) -> T: """Request a list of report formats Args: 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 """ return self._send_and_transform_command( ReportFormats.get_report_formats( filter_string=filter_string, filter_id=filter_id, trash=trash, alerts=alerts, params=params, details=details, ) ) def get_report_format( self, report_format_id: Union[EntityID, ReportFormatType] ) -> T: """Request a single report format Args: report_format_id: UUID of an existing report format or ReportFormatType (enum) """ return self._send_and_transform_command( ReportFormats.get_report_format(report_format_id) ) def import_report_format(self, report_format: str) -> T: """Import a report format from XML Args: report_format: Report format XML as string to import. This XML must contain a :code:`` root element. """ return self._send_and_transform_command( ReportFormats.import_report_format(report_format) ) def modify_report_format( self, report_format_id: Union[EntityID, ReportFormatType], *, active: Optional[bool] = None, name: Optional[str] = None, summary: Optional[str] = None, param_name: Optional[str] = None, param_value: Optional[str] = None, ) -> T: """Modifies an existing report format. Args: 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. """ return self._send_and_transform_command( ReportFormats.modify_report_format( report_format_id, active=active, name=name, summary=summary, param_name=param_name, param_value=param_value, ) ) def verify_report_format( self, report_format_id: Union[EntityID, ReportFormatType] ) -> T: """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. Args: report_format_id: UUID of the report format to be verified or ReportFormatType (enum) """ return self._send_and_transform_command( ReportFormats.verify_report_format(report_format_id) ) python-gvm-24.8.0/gvm/protocols/gmp/_gmp225.py000066400000000000000000000057011466406635600210650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later """ Greenbone Management Protocol (GMP) version 22.5 """ from typing import Optional from .._protocol import T from ._gmp224 import GMPv224 from .requests.v225 import ( ResourceNames, ResourceType, ) class GMPv225(GMPv224[T]): """ A class implementing the Greenbone Management Protocol (GMP) version 22.5 Example: .. code-block:: python from gvm.protocols.gmp import GMPv225 as GMP with GMP(connection) as gmp: resp = gmp.get_tasks() """ def __init__(self, *args, **kwargs): """ Create a new GMPv225 instance. Args: 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 """ super().__init__(*args, **kwargs) @staticmethod def get_protocol_version() -> tuple[int, int]: return (22, 5) def get_resource_names( self, resource_type: ResourceType, *, filter_string: Optional[str] = None, ) -> T: """Request a list of resource names and IDs Arguments: resource_type: Type must be either ALERT, CERT_BUND_ADV, CONFIG, CPE, CREDENTIAL, CVE, DFN_CERT_ADV, FILTER, GROUP, HOST, NOTE, NVT, OS, OVERRIDE, PERMISSION, PORT_LIST, REPORT_FORMAT, REPORT, RESULT, ROLE, SCANNER, SCHEDULE, TARGET, TASK, TLS_CERTIFICATE or USER filter_string: Filter term to use for the query """ return self._send_and_transform_command( ResourceNames.get_resource_names( resource_type, filter_string=filter_string ) ) def get_resource_name( self, resource_id: str, resource_type: ResourceType ) -> T: """Request a single resource name Arguments: resource_id: ID of an existing resource resource_type: Type must be either ALERT, CERT_BUND_ADV, CONFIG, CPE, CREDENTIAL, CVE, DFN_CERT_ADV, FILTER, GROUP, HOST, NOTE, NVT, OS, OVERRIDE, PERMISSION, PORT_LIST, REPORT_FORMAT, REPORT, RESULT, ROLE, SCANNER, SCHEDULE, TARGET, TASK, TLS_CERTIFICATE or USER """ return self._send_and_transform_command( ResourceNames.get_resource_name(resource_id, resource_type) ) python-gvm-24.8.0/gvm/protocols/gmp/requests/000077500000000000000000000000001466406635600212105ustar00rootroot00000000000000python-gvm-24.8.0/gvm/protocols/gmp/requests/__init__.py000066400000000000000000000003101466406635600233130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from ._entity_id import EntityID from ._version import Version __all__ = ( "EntityID", "Version", ) python-gvm-24.8.0/gvm/protocols/gmp/requests/_entity_id.py000066400000000000000000000002471466406635600237140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Union from uuid import UUID EntityID = Union[str, UUID] python-gvm-24.8.0/gvm/protocols/gmp/requests/_version.py000066400000000000000000000006111466406635600234040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from gvm.protocols.core import Request from gvm.xml import XmlCommand class Version: @staticmethod def get_version() -> Request: """Get the Greenbone Vulnerability Management Protocol (GMP) version used by the remote gvmd. """ return XmlCommand("get_version") python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/000077500000000000000000000000001466406635600217055ustar00rootroot00000000000000python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/__init__.py000066400000000000000000000060261466406635600240220ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """ GMP Request implementations for GMP version 22.4. """ from .._entity_id import EntityID from .._version import Version from ._aggregates import Aggregates, AggregateStatistic, SortOrder from ._alerts import AlertCondition, AlertEvent, AlertMethod, Alerts from ._audits import Audits from ._auth import Authentication from ._cert_bund_advisories import CertBundAdvisories from ._cpes import Cpes from ._credentials import ( CredentialFormat, Credentials, CredentialType, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, ) from ._cves import Cves from ._dfn_cert_advisories import DfnCertAdvisories from ._entity_type import EntityType from ._feed import Feed, FeedType from ._filters import Filters, FilterType from ._groups import Groups from ._help import Help, HelpFormat from ._hosts import Hosts, HostsOrdering from ._notes import Notes from ._nvts import Nvts from ._operating_systems import OperatingSystems from ._overrides import Overrides from ._permissions import Permissions, PermissionSubjectType from ._policies import Policies from ._port_lists import PortLists, PortRangeType from ._report_formats import ReportFormats, ReportFormatType from ._reports import Reports from ._results import Results from ._roles import Roles from ._scan_configs import ScanConfigs from ._scanners import Scanners, ScannerType from ._schedules import Schedules from ._secinfo import InfoType, SecInfo from ._severity import Severity from ._system_reports import SystemReports from ._tags import Tags from ._targets import AliveTest, Targets from ._tasks import Tasks from ._tickets import Tickets, TicketStatus from ._tls_certificates import TLSCertificates from ._trashcan import TrashCan from ._user_settings import UserSettings from ._users import UserAuthType, Users from ._vulnerabilities import Vulnerabilities __all__ = ( "Aggregates", "AggregateStatistic", "Alerts", "AlertCondition", "AlertEvent", "AlertMethod", "AliveTest", "Audits", "Authentication", "CertBundAdvisories", "Cpes", "Credentials", "CredentialFormat", "CredentialType", "Cves", "DfnCertAdvisories", "EntityID", "EntityType", "Feed", "FeedType", "Filters", "FilterType", "Groups", "Help", "HelpFormat", "Hosts", "HostsOrdering", "InfoType", "Notes", "Nvts", "OperatingSystems", "Overrides", "Permissions", "PermissionSubjectType", "Policies", "PortLists", "PortRangeType", "ReportFormatType", "ReportFormats", "Reports", "Results", "Roles", "ScanConfigs", "Scanners", "ScannerType", "Schedules", "SecInfo", "Severity", "SortOrder", "SnmpAuthAlgorithm", "SnmpPrivacyAlgorithm", "SystemReports", "Tags", "Targets", "Tasks", "Tickets", "TicketStatus", "TLSCertificates", "TrashCan", "UserAuthType", "UserSettings", "Users", "Version", "Vulnerabilities", ) python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_aggregates.py000066400000000000000000000171411466406635600245330ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Iterable, Optional, Union from gvm._enum import Enum from gvm.errors import InvalidArgumentType, RequiredArgument from gvm.protocols.core import Request from gvm.xml import XmlCommand from .._entity_id import EntityID from ._entity_type import EntityType 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 class SortOrder(Enum): """Enum for sort order""" ASCENDING = "ascending" DESCENDING = "descending" class Aggregates: @classmethod def get_aggregates( cls, resource_type: Union[EntityType, str], *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, sort_criteria: Optional[ Iterable[dict[str, Union[str, SortOrder, AggregateStatistic]]] ] = None, data_columns: Optional[Union[Iterable[str], str]] = None, group_column: Optional[str] = None, subgroup_column: Optional[str] = None, text_columns: Optional[Union[Iterable[str], str]] = None, first_group: Optional[int] = None, max_groups: Optional[int] = None, mode: Optional[int] = None, **kwargs, ) -> Request: """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. Args: 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 """ if not resource_type: raise RequiredArgument( function=cls.get_aggregates.__name__, argument="resource_type" ) if not isinstance(resource_type, EntityType): resource_type = EntityType(resource_type) 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) cmd.add_filter(filter_string, filter_id) if first_group is not None: try: cmd.set_attribute("first_group", str(int(first_group))) except ValueError: raise InvalidArgumentType( argument="first_group", function=cls.get_aggregates.__name__, ) from None if max_groups is not None: try: cmd.set_attribute("max_groups", str(int(max_groups))) except ValueError: raise InvalidArgumentType( argument="first_group", function=cls.get_aggregates.__name__, ) if sort_criteria is not None: if not isinstance(sort_criteria, Iterable) or isinstance( sort_criteria, str ): raise InvalidArgumentType( argument="sort_criteria", function=cls.get_aggregates.__name__, arg_type=getattr(Iterable, "__name__", "Iterable"), ) for sort in sort_criteria: if not isinstance(sort, dict): raise InvalidArgumentType( argument="sort_criteria", function=cls.get_aggregates.__name__, ) sort_elem = cmd.add_element("sort") if sort.get("field"): sort_elem.set_attribute("field", sort.get("field")) # type: ignore if sort.get("stat"): if isinstance(sort["stat"], AggregateStatistic): sort_elem.set_attribute("stat", sort["stat"].value) else: stat = AggregateStatistic(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(sort["order"]) sort_elem.set_attribute("order", so.value) if data_columns is not None: if isinstance(data_columns, str): data_columns = [data_columns] elif not isinstance(data_columns, Iterable): raise InvalidArgumentType( function=cls.get_aggregates.__name__, argument="data_columns", arg_type=getattr(Iterable, "__name__", "Iterable"), ) 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"{cls.get_aggregates.__name__} requires a group_column" " argument if subgroup_column is given", function=cls.get_aggregates.__name__, argument="subgroup_column", ) cmd.set_attribute("subgroup_column", subgroup_column) if text_columns is not None: if isinstance(text_columns, str): text_columns = [text_columns] elif not isinstance(text_columns, Iterable): raise InvalidArgumentType( function=cls.get_aggregates.__name__, argument="text_columns", arg_type=getattr(Iterable, "__name__", "Iterable"), ) for column in text_columns: cmd.add_element("text_column", column) if mode is not None: cmd.set_attribute("mode", str(mode)) # Add additional keyword args as attributes for backward compatibility. cmd.set_attributes(kwargs) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_alerts.py000066400000000000000000000374041466406635600237200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID from ._report_formats import ReportFormatType 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" 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" 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" def _check_event( event: AlertEvent, condition: Optional[AlertCondition], method: Optional[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 Alerts: @classmethod def create_alert( cls, name: str, condition: AlertCondition, event: AlertEvent, method: AlertMethod, *, method_data: Optional[dict[str, str]] = None, event_data: Optional[dict[str, str]] = None, condition_data: Optional[dict[str, str]] = None, filter_id: Optional[EntityID] = None, comment: Optional[str] = None, ) -> Request: """Create a new alert Args: 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 """ if not name: raise RequiredArgument( function=cls.create_alert.__name__, argument="name" ) if not condition: raise RequiredArgument( function=cls.create_alert.__name__, argument="condition" ) if not event: raise RequiredArgument( function=cls.create_alert.__name__, argument="event" ) if not method: raise RequiredArgument( function=cls.create_alert.__name__, argument="method" ) if not isinstance(condition, AlertCondition): condition = AlertCondition(condition) if not isinstance(event, AlertEvent): event = AlertEvent(event) if not isinstance(method, AlertMethod): method = AlertMethod(method) _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(): xml_data = conditions.add_element("data", value) xml_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(): xml_data = events.add_element("data", value) xml_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(): xml_data = methods.add_element("data", value) xml_data.add_element("name", key) if filter_id: cmd.add_element("filter", attrs={"id": filter_id}) if comment: cmd.add_element("comment", comment) return cmd @classmethod def modify_alert( cls, alert_id: EntityID, *, name: Optional[str] = None, comment: Optional[str] = None, filter_id: Optional[EntityID] = None, event: Optional[Union[AlertEvent, str]] = None, event_data: Optional[dict] = None, condition: Optional[Union[AlertCondition, str]] = None, condition_data: Optional[dict[str, str]] = None, method: Optional[Union[AlertMethod, str]] = None, method_data: Optional[dict[str, str]] = None, ) -> Request: """Modify an existing alert. Args: 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 """ if not alert_id: raise RequiredArgument( function=cls.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): condition = AlertCondition(condition) conditions = cmd.add_element("condition", condition.value) if condition_data is not None: for key, value in condition_data.items(): xml_data = conditions.add_element("data", value) xml_data.add_element("name", key) if method: if not isinstance(method, AlertMethod): method = AlertMethod(method) methods = cmd.add_element("method", method.value) if method_data is not None: for key, value in method_data.items(): xml_data = methods.add_element("data", value) xml_data.add_element("name", key) if event: if not isinstance(event, AlertEvent): event = AlertEvent(event) _check_event(event, condition, method) # type: ignore events = cmd.add_element("event", event.value) if event_data is not None: for key, value in event_data.items(): xml_data = events.add_element("data", value) xml_data.add_element("name", key) return cmd @classmethod def clone_alert(cls, alert_id: EntityID) -> Request: """Clone an existing alert Args: alert_id: UUID of the alert to clone from """ if not alert_id: raise RequiredArgument( function=cls.clone_alert.__name__, argument="alert_id" ) cmd = XmlCommand("create_alert") cmd.add_element("copy", str(alert_id)) return cmd @classmethod def delete_alert( cls, alert_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Delete an existing alert Args: alert_id: UUID of the alert to delete ultimate: Whether to remove entirely or to the trashcan. """ if not alert_id: raise RequiredArgument( function=cls.delete_alert.__name__, argument="alert_id" ) cmd = XmlCommand("delete_alert") cmd.set_attribute("alert_id", str(alert_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @classmethod def test_alert(cls, alert_id: EntityID) -> Request: """Run an alert Invoke a test run of an alert Args: alert_id: UUID of the alert to be tested """ if not alert_id: raise RequiredArgument( function=cls.test_alert.__name__, argument="alert_id" ) cmd = XmlCommand("test_alert") cmd.set_attribute("alert_id", str(alert_id)) return cmd @classmethod def trigger_alert( cls, alert_id: EntityID, report_id: EntityID, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, report_format_id: Optional[Union[EntityID, ReportFormatType]] = None, delta_report_id: Optional[EntityID] = None, ) -> Request: """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. Args: 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. """ if not alert_id: raise RequiredArgument( function=cls.trigger_alert.__name__, argument="alert_id argument", ) if not report_id: raise RequiredArgument( function=cls.trigger_alert.__name__, argument="report_id argument", ) cmd = XmlCommand("get_reports") cmd.set_attribute("report_id", str(report_id)) cmd.set_attribute("alert_id", str(alert_id)) cmd.add_filter(filter_string, filter_id) if report_format_id: cmd.set_attribute("format_id", str(report_format_id)) if delta_report_id: cmd.set_attribute("delta_report_id", str(delta_report_id)) return cmd @staticmethod def get_alerts( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> Request: """Request a list of alerts Args: 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 """ cmd = XmlCommand("get_alerts") cmd.add_filter(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 cmd @classmethod def get_alert( cls, alert_id: EntityID, *, tasks: Optional[bool] = None ) -> Request: """Request a single alert Arguments: alert_id: UUID of an existing alert tasks: Whether to include the tasks using the alert """ cmd = XmlCommand("get_alerts") if not alert_id: raise RequiredArgument( function=cls.get_alert.__name__, argument="alert_id" ) cmd.set_attribute("alert_id", str(alert_id)) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_audits.py000066400000000000000000000305611466406635600237140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from numbers import Integral from typing import Optional, Union from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool, to_comma_list from gvm.xml import XmlCommand from .._entity_id import EntityID from ._hosts import HostsOrdering class Audits: @classmethod def create_audit( cls, name: str, policy_id: EntityID, target_id: EntityID, scanner_id: EntityID, *, alterable: Optional[bool] = None, hosts_ordering: Optional[Union[HostsOrdering, str]] = None, schedule_id: Optional[str] = None, alert_ids: Optional[list[EntityID]] = None, comment: Optional[str] = None, schedule_periods: Optional[int] = None, observers: Optional[list[EntityID]] = None, preferences: Optional[dict[str, str]] = None, ) -> Request: """Create a new audit Args: 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. """ if not name: raise RequiredArgument( function=cls.create_audit.__name__, argument="name" ) if not policy_id: raise RequiredArgument( function=cls.create_audit.__name__, argument="policy_id" ) if not target_id: raise RequiredArgument( function=cls.create_audit.__name__, argument="target_id" ) if not scanner_id: raise RequiredArgument( function=cls.create_audit.__name__, argument="scanner_id" ) # don't allow to create a container task with create_task if target_id == "0": raise InvalidArgument( function=cls.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": str(policy_id)}) cmd.add_element("target", attrs={"id": str(target_id)}) cmd.add_element("scanner", attrs={"id": str(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): hosts_ordering = HostsOrdering(hosts_ordering) cmd.add_element("hosts_ordering", hosts_ordering.value) if alert_ids: for alert in alert_ids: cmd.add_element("alert", attrs={"id": str(alert)}) if schedule_id: cmd.add_element("schedule", attrs={"id": str(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: # 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: xml_prefs = cmd.add_element("preferences") for pref_name, pref_value in preferences.items(): xml_pref = xml_prefs.add_element("preference") xml_pref.add_element("scanner_name", pref_name) xml_pref.add_element("value", str(pref_value)) return cmd @classmethod def modify_audit( cls, audit_id: EntityID, *, name: Optional[str] = None, policy_id: Optional[EntityID] = None, target_id: Optional[EntityID] = None, scanner_id: Optional[EntityID] = None, alterable: Optional[bool] = None, hosts_ordering: Optional[Union[str, HostsOrdering]] = None, schedule_id: Optional[EntityID] = None, schedule_periods: Optional[int] = None, comment: Optional[str] = None, alert_ids: Optional[list[EntityID]] = None, observers: Optional[list[EntityID]] = None, preferences: Optional[dict[str, str]] = None, ) -> Request: """Modifies an existing audit. Args: 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. """ if not audit_id: raise RequiredArgument( function=cls.modify_audit.__name__, argument="task_id argument" ) cmd = XmlCommand("modify_task") cmd.set_attribute("task_id", str(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": str(policy_id)}) if target_id: cmd.add_element("target", attrs={"id": str(target_id)}) if alterable is not None: cmd.add_element("alterable", to_bool(alterable)) if hosts_ordering: if not isinstance(hosts_ordering, HostsOrdering): hosts_ordering = HostsOrdering(hosts_ordering) cmd.add_element("hosts_ordering", hosts_ordering.value) if scanner_id: cmd.add_element("scanner", attrs={"id": str(scanner_id)}) if schedule_id: cmd.add_element("schedule", attrs={"id": str(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 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: cmd.add_element("observers", to_comma_list(observers)) if preferences is not None: xml_prefs = cmd.add_element("preferences") for pref_name, pref_value in preferences.items(): xml_pref = xml_prefs.add_element("preference") xml_pref.add_element("scanner_name", pref_name) xml_pref.add_element("value", str(pref_value)) return cmd @classmethod def clone_audit(cls, audit_id: EntityID) -> Request: """Clone an existing audit Args: audit_id: UUID of the audit to clone """ if not audit_id: raise RequiredArgument( function=cls.clone_audit.__name__, argument="task_id" ) cmd = XmlCommand("create_task") cmd.add_element("copy", str(audit_id)) return cmd @classmethod def delete_audit( cls, audit_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Delete an existing audit Args: 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=cls.delete_audit.__name__, argument="task_id" ) cmd = XmlCommand("delete_task") cmd.set_attribute("task_id", str(audit_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_audits( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, details: Optional[bool] = None, schedules_only: Optional[bool] = None, ) -> Request: """Request a list of audits Args: 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 """ cmd = XmlCommand("get_tasks") cmd.set_attribute("usage_type", "audit") cmd.add_filter(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 cmd @classmethod def get_audit(cls, audit_id: EntityID) -> Request: """Request a single audit Args: audit_id: UUID of an existing audit """ if not audit_id: raise RequiredArgument( function=cls.get_audit.__name__, argument="audit_id" ) cmd = XmlCommand("get_tasks") cmd.set_attribute("task_id", str(audit_id)) cmd.set_attribute("usage_type", "audit") # for single entity always request all details cmd.set_attribute("details", "1") return cmd @classmethod def resume_audit(cls, audit_id: EntityID) -> Request: """Resume an existing stopped audit Args: audit_id: UUID of the audit to be resumed """ if not audit_id: raise RequiredArgument( function=cls.resume_audit.__name__, argument="audit_id" ) cmd = XmlCommand("resume_task") cmd.set_attribute("task_id", str(audit_id)) return cmd @classmethod def start_audit(cls, audit_id: EntityID) -> Request: """Start an existing audit Args: audit_id: UUID of the audit to be started """ if not audit_id: raise RequiredArgument( function=cls.start_audit.__name__, argument="audit_id" ) cmd = XmlCommand("start_task") cmd.set_attribute("task_id", str(audit_id)) return cmd @classmethod def stop_audit(cls, audit_id: EntityID) -> Request: """Stop an existing running audit Args: audit_id: UUID of the audit to be stopped """ if not audit_id: raise RequiredArgument( function=cls.stop_audit.__name__, argument="audit_id" ) cmd = XmlCommand("stop_task") cmd.set_attribute("task_id", str(audit_id)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_auth.py000066400000000000000000000044251466406635600233640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.xml import XmlCommand class Authentication: @classmethod def authenticate(cls, username: str, password: str) -> Request: """Authenticate to gvmd. The generated authenticate command will be send to server. Afterwards the response is read, transformed and returned. Args: username: Username password: Password """ cmd = XmlCommand("authenticate") if not username: raise RequiredArgument( function=cls.authenticate.__name__, argument="username" ) if not password: raise RequiredArgument( function=cls.authenticate.__name__, argument="password" ) credentials = cmd.add_element("credentials") credentials.add_element("username", username) credentials.add_element("password", password) return cmd @staticmethod def describe_auth() -> Request: """Describe authentication methods Returns a list of all used authentication methods if such a list is available. """ return XmlCommand("describe_auth") @classmethod def modify_auth( cls, group_name: str, auth_conf_settings: dict[str, str] ) -> Request: """Modifies an existing authentication. Args: group_name: Name of the group to be modified. auth_conf_settings: The new auth config. """ if not group_name: raise RequiredArgument( function=cls.modify_auth.__name__, argument="group_name" ) if not auth_conf_settings: raise RequiredArgument( function=cls.modify_auth.__name__, argument="auth_conf_settings", ) cmd = XmlCommand("modify_auth") group = cmd.add_element("group", attrs={"name": str(group_name)}) for key, value in auth_conf_settings.items(): auth_conf = group.add_element("auth_conf_setting") auth_conf.add_element("key", key) auth_conf.add_element("value", value) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_cert_bund_advisories.py000066400000000000000000000035461466406635600266230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class CertBundAdvisories: @staticmethod def get_cert_bund_advisories( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Request: """Request a list of CERT-BUND Advisories Args: 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 """ cmd = XmlCommand("get_info") cmd.set_attribute("type", "CERT_BUND_ADV") cmd.add_filter(filter_string, filter_id) if name: cmd.set_attribute("name", name) if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def get_cert_bund_advisory(cls, cert_id: EntityID) -> Request: """Request a single CERT-BUND Advisory Args: cert_id: ID of an existing CERT-BUND Advisory """ if not cert_id: raise RequiredArgument( function=cls.get_cert_bund_advisory.__name__, argument="cert_id" ) cmd = XmlCommand("get_info") cmd.set_attribute("info_id", str(cert_id)) cmd.set_attribute("type", "CERT_BUND_ADV") # for single entity always request all details cmd.set_attribute("details", "1") return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_cpes.py000066400000000000000000000033321466406635600233510ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class Cpes: @staticmethod def get_cpes( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Request: """Request a list of CPEs Args: 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 """ cmd = XmlCommand("get_info") cmd.set_attribute("type", "CPE") cmd.add_filter(filter_string, filter_id) if name: cmd.set_attribute("name", name) if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def get_cpe(cls, cpe_id: str) -> Request: """Request a single CPE Args: cpe_id: ID of an existing CPE """ if not cpe_id: raise RequiredArgument( function=cls.get_cpe.__name__, argument="cpe_id" ) cmd = XmlCommand("get_info") cmd.set_attribute("info_id", cpe_id) cmd.set_attribute("type", "CPE") # for single entity always request all details cmd.set_attribute("details", "1") return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_credentials.py000066400000000000000000000432561466406635600247250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class CredentialFormat(Enum): """Enum for credential format""" KEY = "key" RPM = "rpm" DEB = "deb" EXE = "exe" PEM = "pem" 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" class SnmpAuthAlgorithm(Enum): """Enum for SNMP auth algorithm""" SHA1 = "sha1" MD5 = "md5" class SnmpPrivacyAlgorithm(Enum): """Enum for SNMP privacy algorithm""" AES = "aes" DES = "des" class Credentials: @classmethod def clone_credential(cls, credential_id: EntityID) -> Request: """Clone a credential Args: credential_id: The ID of the credential to clone """ if not credential_id: raise RequiredArgument( function=cls.clone_credential.__name__, argument="credential_id", ) cmd = XmlCommand("create_credential") cmd.add_element("copy", str(credential_id)) return cmd @classmethod def create_credential( cls, name: str, credential_type: Union[CredentialType, str], *, 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[Union[SnmpAuthAlgorithm, str]] = None, community: Optional[str] = None, privacy_algorithm: Optional[Union[SnmpPrivacyAlgorithm, str]] = None, privacy_password: Optional[str] = None, public_key: Optional[str] = None, ) -> Request: """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 request = Credentials.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() request = Credentials.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() request = Credentials.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() request = Credentials.create_credential( name='SMIME Credential', credential_type=CredentialType.SMIME_CERTIFICATE, certificate=cert, ) Creating a Password-Only credential .. code-block:: python request = Credentials.create_credential( name='Password-Only Credential', credential_type=CredentialType.PASSWORD_ONLY, password='foo', ) Creating an auto-generated password .. code-block:: python request = Credentials.create_credential( name='UP Credential', credential_type=CredentialType.USERNAME_PASSWORD, login='foo', ) Creating an auto-generated SSH-Key credential .. code-block:: python request = Credentials.create_credential( name='USK Credential', credential_type=CredentialType.USERNAME_SSH_KEY, login='foo', ) """ if not name: raise RequiredArgument( function=cls.create_credential.__name__, argument="name" ) if not credential_type: raise RequiredArgument( function=cls.create_credential.__name__, argument="credential_type", ) if not isinstance(credential_type, CredentialType): credential_type = CredentialType(credential_type) 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=cls.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=cls.create_credential.__name__, argument="login" ) cmd.add_element("login", login) if credential_type == CredentialType.PASSWORD_ONLY and not password: raise RequiredArgument( function=cls.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 and private_key is not None ): if not private_key: raise RequiredArgument( function=cls.create_credential.__name__, argument="private_key", ) xml_key = cmd.add_element("key") xml_key.add_element("private", private_key) if key_phrase: xml_key.add_element("phrase", key_phrase) if credential_type == CredentialType.CLIENT_CERTIFICATE and private_key: xml_key = cmd.add_element("key") xml_key.add_element("private", private_key) if credential_type == CredentialType.SNMP: if not auth_algorithm: raise RequiredArgument( function=cls.create_credential.__name__, argument="auth_algorithm", ) if not isinstance(auth_algorithm, SnmpAuthAlgorithm): auth_algorithm = SnmpAuthAlgorithm(auth_algorithm) cmd.add_element("auth_algorithm", auth_algorithm.value) if community: cmd.add_element("community", community) if privacy_algorithm is not None or privacy_password: xml_privacy = cmd.add_element("privacy") if privacy_algorithm is not None: if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm): privacy_algorithm = SnmpPrivacyAlgorithm( privacy_algorithm ) xml_privacy.add_element( "algorithm", privacy_algorithm.value ) if privacy_password: xml_privacy.add_element("password", privacy_password) if credential_type == CredentialType.PGP_ENCRYPTION_KEY: if not public_key: raise RequiredArgument( function=cls.create_credential.__name__, argument="public_key", ) xml_key = cmd.add_element("key") xml_key.add_element("public", public_key) return cmd @classmethod def delete_credential( cls, credential_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Delete a credential Args: credential_id: The ID of the credential to delete ultimate: Whether to remove entirely, or to the trashcan. """ if not credential_id: raise RequiredArgument( function=cls.delete_credential.__name__, argument="credential_id", ) cmd = XmlCommand("delete_credential") cmd.set_attribute("credential_id", str(credential_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_credentials( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, scanners: Optional[bool] = None, trash: Optional[bool] = None, targets: Optional[bool] = None, ) -> Request: """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 """ cmd = XmlCommand("get_credentials") cmd.add_filter(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 cmd @classmethod def get_credential( cls, credential_id: EntityID, *, scanners: Optional[bool] = None, targets: Optional[bool] = None, credential_format: Optional[Union[CredentialFormat, str]] = None, ) -> Request: """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" """ if not credential_id: raise RequiredArgument( function=cls.get_credential.__name__, argument="credential_id" ) cmd = XmlCommand("get_credentials") cmd.set_attribute("credential_id", str(credential_id)) if credential_format: if not isinstance(credential_format, CredentialFormat): credential_format = CredentialFormat(credential_format) 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 cmd @classmethod def modify_credential( cls, credential_id: EntityID, *, 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[Union[SnmpAuthAlgorithm, str]] = None, community: Optional[str] = None, privacy_algorithm: Optional[Union[SnmpPrivacyAlgorithm, str]] = None, privacy_password: Optional[str] = None, public_key: Optional[str] = None, ) -> Request: """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 """ if not credential_id: raise RequiredArgument( function=cls.modify_credential.__name__, argument="credential_id", ) cmd = XmlCommand("modify_credential") cmd.set_attribute("credential_id", str(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: xml_key = cmd.add_element("key") xml_key.add_element("phrase", key_phrase) xml_key.add_element("private", private_key) elif (not key_phrase and private_key) or ( key_phrase and not private_key ): raise RequiredArgument( function=cls.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): auth_algorithm = SnmpAuthAlgorithm(auth_algorithm) 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: xml_privacy = cmd.add_element("privacy") if privacy_algorithm is not None: if not isinstance(privacy_algorithm, SnmpPrivacyAlgorithm): privacy_algorithm = SnmpPrivacyAlgorithm(privacy_algorithm) xml_privacy.add_element("algorithm", privacy_algorithm.value) if privacy_password is not None: xml_privacy.add_element("password", privacy_password) if public_key: xml_key = cmd.add_element("key") xml_key.add_element("public", public_key) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_cves.py000066400000000000000000000033321466406635600233570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class Cves: @staticmethod def get_cves( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Request: """Request a list of CVEs Args: 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 """ cmd = XmlCommand("get_info") cmd.set_attribute("type", "CVE") cmd.add_filter(filter_string, filter_id) if name: cmd.set_attribute("name", name) if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def get_cve(cls, cve_id: str) -> Request: """Request a single CVE Args: cve_id: ID of an existing CVE """ if not cve_id: raise RequiredArgument( function=cls.get_cve.__name__, argument="cve_id" ) cmd = XmlCommand("get_info") cmd.set_attribute("info_id", cve_id) cmd.set_attribute("type", "CVE") # for single entity always request all details cmd.set_attribute("details", "1") return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_dfn_cert_advisories.py000066400000000000000000000035361466406635600264410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class DfnCertAdvisories: @staticmethod def get_dfn_cert_advisories( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Request: """Request a list of DFN-CERT Advisories Args: 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 """ cmd = XmlCommand("get_info") cmd.set_attribute("type", "DFN_CERT_ADV") cmd.add_filter(filter_string, filter_id) if name: cmd.set_attribute("name", name) if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def get_dfn_cert_advisory(cls, cert_id: EntityID) -> Request: """Request a single DFN-CERT Advisory Args: cert_id: ID of an existing DFN-CERT Advisory """ if not cert_id: raise RequiredArgument( function=cls.get_dfn_cert_advisory.__name__, argument="cert_id" ) cmd = XmlCommand("get_info") cmd.set_attribute("info_id", str(cert_id)) cmd.set_attribute("type", "DFN_CERT_ADV") # for single entity always request all details cmd.set_attribute("details", "1") return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_entity_type.py000066400000000000000000000030401466406635600247700ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm._enum import Enum 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 entity_type == "vuln": return cls.VULNERABILITY if entity_type == "os": return cls.OPERATING_SYSTEM if entity_type == "config": return cls.SCAN_CONFIG return super().from_string(entity_type) python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_feed.py000066400000000000000000000021131466406635600233160ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Union from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.xml import XmlCommand class FeedType(Enum): """Enum for feed types""" NVT = "NVT" CERT = "CERT" SCAP = "SCAP" GVMD_DATA = "GVMD_DATA" class Feed: @staticmethod def get_feeds() -> Request: """Request the list of feeds""" return XmlCommand("get_feeds") @classmethod def get_feed(cls, feed_type: Union[FeedType, str]) -> Request: """Request a single feed Arguments: feed_type: Type of single feed to get: NVT, CERT or SCAP """ if not feed_type: raise RequiredArgument( function=cls.get_feed.__name__, argument="feed_type" ) if not isinstance(feed_type, FeedType): feed_type = FeedType(feed_type) cmd = XmlCommand("get_feeds") cmd.set_attribute("type", feed_type.value) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_filters.py000066400000000000000000000145061466406635600240740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID 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 Args: filter_type (str): Filter type string to convert to a FilterType """ 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 return super().from_string(filter_type) class Filters: @classmethod def clone_filter(cls, filter_id: EntityID) -> Request: """Clone a filter Args: filter_id: ID of the filter to clone """ if not filter_id: raise RequiredArgument( function=cls.clone_filter.__name__, argument="filter_id" ) cmd = XmlCommand("create_filter") cmd.add_element("copy", str(filter_id)) return cmd @classmethod def create_filter( cls, name: str, *, filter_type: Optional[FilterType] = None, comment: Optional[str] = None, term: Optional[str] = None, ) -> Request: """Create a new filter Args: name: Name of the new filter filter_type: Filter for entity type comment: Comment for the filter term: Filter term e.g. 'name=foo' """ if not name: raise RequiredArgument( function=cls.create_filter.__name__, argument="name" ) cmd = XmlCommand("create_filter") 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): filter_type = FilterType(filter_type) cmd.add_element("type", filter_type.value) return cmd @classmethod def delete_filter( cls, filter_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing filter Args: 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=cls.delete_filter.__name__, argument="filter_id" ) cmd = XmlCommand("delete_filter") cmd.set_attribute("filter_id", str(filter_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_filters( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, alerts: Optional[bool] = None, ) -> Request: """Request a list of filters Args: 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. """ cmd = XmlCommand("get_filters") cmd.add_filter(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 cmd @classmethod def get_filter( cls, filter_id: EntityID, *, alerts: Optional[bool] = None ) -> Request: """Request a single filter Args: filter_id: UUID of an existing filter alerts: Whether to include list of alerts that use the filter. """ cmd = XmlCommand("get_filters") if not filter_id: raise RequiredArgument( function=cls.get_filter.__name__, argument="filter_id" ) cmd.set_attribute("filter_id", str(filter_id)) if alerts is not None: cmd.set_attribute("alerts", to_bool(alerts)) return cmd @classmethod def modify_filter( cls, filter_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, term: Optional[str] = None, filter_type: Optional[FilterType] = None, ) -> Request: """Modifies an existing filter. Args: 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. """ if not filter_id: raise RequiredArgument( function=cls.modify_filter.__name__, argument="filter_id" ) cmd = XmlCommand("modify_filter") cmd.set_attribute("filter_id", str(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): filter_type = FilterType(filter_type) cmd.add_element("type", filter_type.value) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_groups.py000066400000000000000000000105711466406635600237410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool, to_comma_list from gvm.xml import XmlCommand from .._entity_id import EntityID class Groups: @classmethod def clone_group(cls, group_id: EntityID) -> Request: """Clone an existing group Args: group_id: UUID of an existing group to clone from """ if not group_id: raise RequiredArgument( function=cls.clone_group.__name__, argument="group_id" ) cmd = XmlCommand("create_group") cmd.add_element("copy", str(group_id)) return cmd @classmethod def create_group( cls, name: str, *, comment: Optional[str] = None, special: Optional[bool] = False, users: Optional[list[str]] = None, ) -> Request: """Create a new group Args: 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 """ if not name: raise RequiredArgument( function=cls.create_group.__name__, argument="name" ) cmd = XmlCommand("create_group") cmd.add_element("name", name) if comment: cmd.add_element("comment", comment) if special: xml_special = cmd.add_element("specials") xml_special.add_element("full") if users: cmd.add_element("users", to_comma_list(users)) return cmd @classmethod def delete_group( cls, group_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing group Args: 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=cls.delete_group.__name__, argument="group_id" ) cmd = XmlCommand("delete_group") cmd.set_attribute("group_id", str(group_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_groups( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, ) -> Request: """Request a list of groups Args: 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 """ cmd = XmlCommand("get_groups") cmd.add_filter(filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return cmd @classmethod def get_group(cls, group_id: EntityID) -> Request: """Request a single group Args: group_id: UUID of an existing group """ cmd = XmlCommand("get_groups") if not group_id: raise RequiredArgument( function=cls.get_group.__name__, argument="group_id" ) cmd.set_attribute("group_id", str(group_id)) return cmd @classmethod def modify_group( cls, group_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, users: Optional[list[str]] = None, ) -> Request: """Modifies an existing group. Args: 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 """ if not group_id: raise RequiredArgument( function=cls.modify_group.__name__, argument="group_id" ) cmd = XmlCommand("modify_group") cmd.set_attribute("group_id", str(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 cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_help.py000066400000000000000000000021051466406635600233440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.protocols.core import Request from gvm.xml import XmlCommand class HelpFormat(Enum): """Enum for the help format""" HTML = "html" RNC = "rnc" TEXT = "text" XML = "xml" class Help: @staticmethod def help( *, help_format: Optional[Union[HelpFormat, str]] = None, brief: Optional[bool] = None, ) -> Request: """Get the help text Arguments: help_format: Format of of the help: "html", "rnc", "text" or "xml brief: If True help is brief """ 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): help_format = HelpFormat(help_format) cmd.set_attribute("format", help_format.value) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_hosts.py000066400000000000000000000072341466406635600235640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class HostsOrdering(Enum): """Enum for host ordering during scans""" SEQUENTIAL = "sequential" RANDOM = "random" REVERSE = "reverse" class Hosts: @classmethod def create_host( cls, name: str, *, comment: Optional[str] = None ) -> Request: """Create a new host host Args: name: Name for the new host host comment: Comment for the new host host """ if not name: raise RequiredArgument( function=cls.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 cmd @classmethod def delete_host(cls, host_id: EntityID) -> Request: """Deletes an existing host Args: host_id: UUID of the single host to delete. """ if not host_id: raise RequiredArgument( function=cls.delete_host.__name__, argument="host_id", ) cmd = XmlCommand("delete_asset") cmd.set_attribute("asset_id", str(host_id)) return cmd @staticmethod def get_hosts( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, ) -> Request: """Request a list of hosts Args: 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 additional information (e.g. tags) """ cmd = XmlCommand("get_assets") cmd.set_attribute("type", "host") cmd.add_filter(filter_string, filter_id) if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def get_host( cls, host_id: EntityID, *, details: Optional[bool] = None ) -> Request: """Request a single host Arguments: host_id: UUID of an existing host details: Whether to include additional information (e.g. tags) """ cmd = XmlCommand("get_assets") if not host_id: raise RequiredArgument( function=cls.get_host.__name__, argument="host_id" ) cmd.set_attribute("asset_id", str(host_id)) cmd.set_attribute("type", "host") if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def modify_host( cls, host_id: EntityID, *, comment: Optional[str] = None ) -> Request: """Modifies an existing host. Args: 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. """ if not host_id: raise RequiredArgument( function=cls.modify_host.__name__, argument="host_id" ) cmd = XmlCommand("modify_asset") cmd.set_attribute("asset_id", str(host_id)) if not comment: comment = "" cmd.add_element("comment", comment) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_notes.py000066400000000000000000000155471466406635600235620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import check_port, to_bool, to_comma_list from gvm.xml import XmlCommand from .._entity_id import EntityID from ._severity import Severity class Notes: @classmethod def create_note( cls, text: str, nvt_oid: str, *, days_active: Optional[int] = None, hosts: Optional[list[str]] = None, port: Optional[str] = None, result_id: Optional[EntityID] = None, severity: Optional[Severity] = None, task_id: Optional[EntityID] = None, ) -> Request: """Create a new note Args: 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 host addresses port: Port to which the override applies, needs to be a string in the form {number}/{protocol} 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 """ if not text: raise RequiredArgument( function=cls.create_note.__name__, argument="text" ) if not nvt_oid: raise RequiredArgument( function=cls.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: if check_port(port): cmd.add_element("port", port) else: raise InvalidArgument( function=cls.create_note.__name__, argument="port" ) if result_id: cmd.add_element("result", attrs={"id": str(result_id)}) if severity is not None: cmd.add_element("severity", str(severity)) if task_id: cmd.add_element("task", attrs={"id": str(task_id)}) return cmd @classmethod def modify_note( cls, note_id: EntityID, text: str, *, days_active: Optional[int] = None, hosts: Optional[list[str]] = None, port: Optional[str] = None, result_id: Optional[EntityID] = None, severity: Optional[Severity] = None, task_id: Optional[EntityID] = None, ) -> Request: """Modify a note Args: note_id: The UUID of the note to modify text: Text of the note days_active: Days note will be active. -1 on always, 0 off hosts: A list of host addresses port: Port to which the override applies, needs to be a string in the form {number}/{protocol} 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 """ if not note_id: raise RequiredArgument( function=cls.modify_note.__name__, argument="note_id" ) if not text: raise RequiredArgument( function=cls.modify_note.__name__, argument="text" ) cmd = XmlCommand("modify_note") cmd.set_attribute("note_id", str(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: if check_port(port): cmd.add_element("port", port) else: raise InvalidArgument( function=cls.modify_note.__name__, argument="port" ) if result_id: cmd.add_element("result", attrs={"id": str(result_id)}) if severity is not None: cmd.add_element("severity", str(severity)) if task_id: cmd.add_element("task", attrs={"id": str(task_id)}) return cmd @classmethod def clone_note(cls, note_id: EntityID) -> Request: """Clone an existing note Args: note_id: UUID of an existing note to clone from """ if not note_id: raise RequiredArgument( function=cls.clone_note.__name__, argument="note_id" ) cmd = XmlCommand("create_note") cmd.add_element("copy", str(note_id)) return cmd @classmethod def delete_note( cls, note_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Delete an existing note Args: 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=cls.delete_note.__name__, argument="note_id" ) cmd = XmlCommand("delete_note") cmd.set_attribute("note_id", str(note_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @classmethod def get_notes( cls, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, result: Optional[bool] = None, ) -> Request: """Request a list of notes Args: filter_string: Filter notes by a string 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. """ cmd = XmlCommand("get_notes") cmd.add_filter(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 cmd @classmethod def get_note(cls, note_id: EntityID) -> Request: """Request a single note Arguments: note_id: UUID of an existing note """ if not note_id: raise RequiredArgument( function=cls.get_note.__name__, argument="note_id" ) cmd = XmlCommand("get_notes") cmd.set_attribute("note_id", str(note_id)) # for single entity always request all details cmd.set_attribute("details", "1") return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_nvts.py000066400000000000000000000171351466406635600234170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class Nvts: @staticmethod def get_nvt_families(*, sort_order: Optional[str] = None) -> Request: """Request a list of nvt families Args: sort_order: Sort order """ cmd = XmlCommand("get_nvt_families") if sort_order: cmd.set_attribute("sort_order", sort_order) return cmd @staticmethod def get_scan_config_nvts( *, details: Optional[bool] = None, preferences: Optional[bool] = None, preference_count: Optional[bool] = None, timeout: Optional[bool] = None, config_id: Optional[EntityID] = None, preferences_config_id: Optional[EntityID] = None, family: Optional[str] = None, sort_order: Optional[str] = None, sort_field: Optional[str] = None, ) -> Request: """Request a list of nvts Args: 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 """ 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", str(config_id)) if preferences_config_id: cmd.set_attribute( "preferences_config_id", str(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 cmd @classmethod def get_scan_config_nvt(cls, nvt_oid: str) -> Request: """Request a single nvt Args: nvt_oid: OID of an existing nvt """ cmd = XmlCommand("get_nvts") if not nvt_oid: raise RequiredArgument( function=cls.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 cmd @classmethod def get_nvts( cls, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, extended: 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: """Request a list of NVTs Args: 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 extended: Whether to receive extended NVT information (calls get_nvts, instead of get_info) preferences: Whether to include NVT preferences (only for extended) preference_count: Whether to include preference count (only for extended) timeout: Whether to include the special timeout preference (only for extended) config_id: UUID of scan config to which to limit the NVT listing (only for extended) preferences_config_id: UUID of scan config to use for preference values (only for extended) family: Family to which to limit NVT listing (only for extended) sort_order: Sort order (only for extended) sort_field: Sort field (only for extended) """ if extended: return cls.get_scan_config_nvts( details=details, preferences=preferences, preference_count=preference_count, timeout=timeout, config_id=config_id, preferences_config_id=preferences_config_id, family=family, sort_order=sort_order, sort_field=sort_field, ) cmd = XmlCommand("get_info") cmd.set_attribute("type", "NVT") cmd.add_filter(filter_string, filter_id) if name: cmd.set_attribute("name", name) if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def get_nvt( cls, nvt_id: str, *, extended: Optional[bool] = None ) -> Request: """Request a single NVT Args: nvt_id: ID of an existing NVT extended: Whether to receive extended NVT information (calls get_nvts, instead of get_info) """ if not nvt_id: raise RequiredArgument( function=cls.get_nvt.__name__, argument="nvt_id" ) if extended: return cls.get_scan_config_nvt(nvt_id) cmd = XmlCommand("get_info") cmd.set_attribute("info_id", nvt_id) cmd.set_attribute("type", "NVT") # for single entity always request all details cmd.set_attribute("details", "1") return cmd @staticmethod def get_nvt_preferences( *, nvt_oid: Optional[str] = None, ) -> Request: """Request a list of preferences The preference element includes just the name and value, with the NVT and type built into the name. Args: nvt_oid: OID of nvt """ cmd = XmlCommand("get_preferences") if nvt_oid: cmd.set_attribute("nvt_oid", nvt_oid) return cmd @classmethod def get_nvt_preference( cls, name: str, *, nvt_oid: Optional[str] = None, ) -> Request: """Request a nvt preference Args: name: name of a particular preference nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values """ cmd = XmlCommand("get_preferences") if not name: raise RequiredArgument( function=cls.get_nvt_preference.__name__, argument="name" ) cmd.set_attribute("preference", name) if nvt_oid: cmd.set_attribute("nvt_oid", nvt_oid) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_operating_systems.py000066400000000000000000000064031466406635600262000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class OperatingSystems: @classmethod def delete_operating_system( cls, operating_system_id: EntityID, ) -> Request: """Deletes an existing operating system Args: operating_system_id: UUID of the single operating_system to delete. """ if not operating_system_id: raise RequiredArgument( function=cls.delete_operating_system.__name__, argument="operating_system_id", ) cmd = XmlCommand("delete_asset") cmd.set_attribute("asset_id", str(operating_system_id)) return cmd @staticmethod def get_operating_systems( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, ) -> Request: """Request a list of operating systems Args: 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 additional information (e.g. tags) """ cmd = XmlCommand("get_assets") cmd.set_attribute("type", "os") cmd.add_filter(filter_string, filter_id) if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def get_operating_system( cls, operating_system_id: EntityID, *, details: Optional[bool] = None ) -> Request: """Request a single operating system Args: operating_system_id: UUID of an existing operating_system details: Whether to include additional information (e.g. tags) """ cmd = XmlCommand("get_assets") if not operating_system_id: raise RequiredArgument( function=cls.get_operating_system.__name__, argument="operating_system_id", ) cmd.set_attribute("asset_id", str(operating_system_id)) cmd.set_attribute("type", "os") if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd @classmethod def modify_operating_system( cls, operating_system_id: EntityID, *, comment: Optional[str] = None ) -> Request: """Modifies an existing operating system. Args: 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. """ if not operating_system_id: raise RequiredArgument( function=cls.modify_operating_system.__name__, argument="operating_system_id", ) cmd = XmlCommand("modify_asset") cmd.set_attribute("asset_id", str(operating_system_id)) if not comment: comment = "" cmd.add_element("comment", comment) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_overrides.py000066400000000000000000000166561466406635600244360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import check_port, to_bool, to_comma_list from gvm.xml import XmlCommand from .._entity_id import EntityID from ._severity import Severity class Overrides: @classmethod def create_override( cls, text: str, nvt_oid: str, *, days_active: Optional[int] = None, hosts: Optional[list[str]] = None, port: Optional[str] = None, result_id: Optional[EntityID] = None, severity: Optional[Severity] = None, new_severity: Optional[Severity] = None, task_id: Optional[EntityID] = None, ) -> Request: """Create a new override Args: 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, needs to be a string in the form {number}/{protocol} 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 """ if not text: raise RequiredArgument( function=cls.create_override.__name__, argument="text" ) if not nvt_oid: raise RequiredArgument( function=cls.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: if check_port(port): cmd.add_element("port", port) else: raise InvalidArgument( function=cls.create_override.__name__, argument="port" ) if result_id: cmd.add_element("result", attrs={"id": result_id}) if severity is not None: cmd.add_element("severity", str(severity)) if new_severity is not None: cmd.add_element("new_severity", str(new_severity)) if task_id: cmd.add_element("task", attrs={"id": task_id}) return cmd @classmethod def modify_override( cls, override_id: EntityID, text: str, *, days_active: Optional[int] = None, hosts: Optional[list[str]] = None, port: Optional[str] = None, result_id: Optional[EntityID] = None, severity: Optional[Severity] = None, new_severity: Optional[Severity] = None, task_id: Optional[EntityID] = None, ) -> Request: """Modify an existing override. Args: 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 the override applies, needs to be a string in the form {number}/{protocol} 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. """ if not override_id: raise RequiredArgument( function=cls.modify_override.__name__, argument="override_id" ) if not text: raise RequiredArgument( function=cls.modify_override.__name__, argument="text" ) cmd = XmlCommand("modify_override") cmd.set_attribute("override_id", str(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: if check_port(port): cmd.add_element("port", str(port)) else: raise InvalidArgument( function=cls.modify_override.__name__, argument="port" ) if result_id: cmd.add_element("result", attrs={"id": str(result_id)}) if severity is not None: cmd.add_element("severity", str(severity)) if new_severity is not None: cmd.add_element("new_severity", str(new_severity)) if task_id: cmd.add_element("task", attrs={"id": str(task_id)}) return cmd @classmethod def clone_override(cls, override_id: EntityID) -> Request: """Clone an existing override Args: override_id: UUID of an existing override to clone from """ if not override_id: raise RequiredArgument( function=cls.clone_override.__name__, argument="override_id" ) cmd = XmlCommand("create_override") cmd.add_element("copy", str(override_id)) return cmd @classmethod def delete_override( cls, override_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Delete an existing override Args: override_id: UUID of an existing override to delete ultimate: Whether to remove entirely, or to the trashcan. """ if not override_id: raise RequiredArgument( function=cls.delete_override.__name__, argument="override_id" ) cmd = XmlCommand("delete_override") cmd.set_attribute("override_id", str(override_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_overrides( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, result: Optional[bool] = None, ) -> Request: """Request a list of overrides Args: 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 """ cmd = XmlCommand("get_overrides") cmd.add_filter(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 cmd @classmethod def get_override(cls, override_id: EntityID) -> Request: """Request a single override Args: override_id: UUID of an existing override """ cmd = XmlCommand("get_overrides") if not override_id: raise RequiredArgument( function=cls.get_override.__name__, argument="override_id" ) cmd.set_attribute("override_id", str(override_id)) # for single entity always request all details cmd.set_attribute("details", "1") return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_permissions.py000066400000000000000000000210251466406635600247710ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID from ._entity_type import EntityType class PermissionSubjectType(Enum): """Enum for permission subject type""" USER = "user" GROUP = "group" ROLE = "role" class Permissions: @classmethod def clone_permission(cls, permission_id: EntityID) -> Request: """Clone an existing permission Args: permission_id: UUID of an existing permission to clone from """ if not permission_id: raise RequiredArgument( function=cls.clone_permission.__name__, argument="permission_id", ) cmd = XmlCommand("create_permission") cmd.add_element("copy", str(permission_id)) return cmd @classmethod def create_permission( cls, name: str, subject_id: EntityID, subject_type: Union[PermissionSubjectType, str], *, resource_id: Optional[str] = None, resource_type: Optional[Union[EntityType, str]] = None, comment: Optional[str] = None, ) -> Request: """Create a new permission Args: 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 """ if not name: raise RequiredArgument( function=cls.create_permission.__name__, argument="name" ) if not subject_id: raise RequiredArgument( function=cls.create_permission.__name__, argument="subject_id" ) if not isinstance(subject_type, PermissionSubjectType): subject_type = PermissionSubjectType(subject_type) cmd = XmlCommand("create_permission") cmd.add_element("name", name) xml_subject = cmd.add_element("subject", attrs={"id": str(subject_id)}) xml_subject.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=cls.create_permission.__name__, argument="resource_id", ) if not resource_type: raise RequiredArgument( function=cls.create_permission.__name__, argument="resource_type", ) if not isinstance(resource_type, EntityType): resource_type = EntityType(resource_type) xml_resource = 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 xml_resource.add_element("type", actual_resource_type.value) return cmd @classmethod def delete_permission( cls, permission_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing permission Args: 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=cls.delete_permission.__name__, argument="permission_id", ) cmd = XmlCommand("delete_permission") cmd.set_attribute("permission_id", str(permission_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_permissions( *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, trash: Optional[bool] = None, ) -> Request: """Request a list of permissions Args: 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 """ cmd = XmlCommand("get_permissions") cmd.add_filter(filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return cmd @classmethod def get_permission(cls, permission_id: EntityID) -> Request: """Request a single permission Args: permission_id: UUID of an existing permission """ cmd = XmlCommand("get_permissions") if not permission_id: raise RequiredArgument( function=cls.get_permission.__name__, argument="permission_id" ) cmd.set_attribute("permission_id", str(permission_id)) return cmd @classmethod def modify_permission( cls, permission_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, resource_id: Optional[EntityID] = None, resource_type: Optional[Union[EntityType, str]] = None, subject_id: Optional[EntityID] = None, subject_type: Optional[Union[PermissionSubjectType, str]] = None, ) -> Request: """Modifies an existing permission. Args: 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 """ if not permission_id: raise RequiredArgument( function=cls.modify_permission.__name__, argument="permission_id", ) cmd = XmlCommand("modify_permission") cmd.set_attribute("permission_id", str(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=cls.modify_permission.__name__, argument="resource_id", ) if not resource_type: raise RequiredArgument( function=cls.modify_permission.__name__, argument="resource_type", ) if not isinstance(resource_type, EntityType): resource_type = EntityType(resource_type) xml_resource = cmd.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 xml_resource.add_element("type", actual_resource_type.value) if subject_id or subject_type: if not subject_id: raise RequiredArgument( function=cls.modify_permission.__name__, argument="subject_id", ) if not subject_type: raise RequiredArgument( function=cls.modify_permission.__name__, argument="subject_type", ) if not isinstance(subject_type, PermissionSubjectType): subject_type = PermissionSubjectType(subject_type) xml_subject = cmd.add_element( "subject", attrs={"id": str(subject_id)} ) xml_subject.add_element("type", subject_type.value) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_policies.py000066400000000000000000000315511466406635600242320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Sequence from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_base64, to_bool from gvm.xml import XmlCommand, XmlError from .._entity_id import EntityID _EMPTY_POLICY_ID = "085569ce-73ed-11df-83c3-002264764cea" class Policies: @classmethod def clone_policy(cls, policy_id: EntityID) -> Request: """Clone a policy from an existing one Args: policy_id: UUID of the existing policy """ if not policy_id: raise RequiredArgument( function=cls.clone_policy.__name__, argument="policy_id" ) cmd = XmlCommand("create_config") cmd.add_element("copy", str(policy_id)) return cmd @classmethod def create_policy( cls, name: str, *, policy_id: Optional[EntityID] = None, comment: Optional[str] = None, ) -> Request: """Create a new policy Args: 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 """ cmd = XmlCommand("create_config") if policy_id is None: policy_id = _EMPTY_POLICY_ID if not name: raise RequiredArgument( function=cls.create_policy.__name__, argument="name" ) if comment is not None: cmd.add_element("comment", comment) cmd.add_element("copy", str(policy_id)) cmd.add_element("name", name) cmd.add_element("usage_type", "policy") return cmd @classmethod def delete_policy( cls, policy_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing policy Args: 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=cls.delete_policy.__name__, argument="policy_id" ) cmd = XmlCommand("delete_config") cmd.set_attribute("config_id", str(policy_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_policies( *, audits: Optional[bool] = None, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, families: Optional[bool] = None, preferences: Optional[bool] = None, trash: Optional[bool] = None, ) -> Request: """Request a list of policies Args: 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 """ cmd = XmlCommand("get_configs") cmd.set_attribute("usage_type", "policy") cmd.add_filter(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 cmd @classmethod def get_policy( cls, policy_id: EntityID, *, audits: Optional[bool] = None ) -> Request: """Request a single policy Args: policy_id: UUID of an existing policy audits: Whether to get audits using this policy """ if not policy_id: raise RequiredArgument( function=cls.get_policy.__name__, argument="policy_id" ) cmd = XmlCommand("get_configs") cmd.set_attribute("config_id", str(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 cmd @classmethod def import_policy(cls, policy: str) -> Request: """Import a policy from XML Args: policy: Policy XML as string to import. This XML must contain a :code:`` root element. """ if not policy: raise RequiredArgument( function=cls.import_policy.__name__, argument="policy" ) cmd = XmlCommand("create_config") try: cmd.append_xml_str(policy) except XmlError as e: raise InvalidArgument( function=cls.import_policy.__name__, argument="policy" ) from e return cmd @classmethod def modify_policy_set_nvt_preference( cls, policy_id: EntityID, name: str, nvt_oid: str, *, value: Optional[str] = None, ) -> Request: """Modifies the nvt preferences of an existing policy. Args: 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=cls.modify_policy_set_nvt_preference.__name__, argument="policy_id", ) if not nvt_oid: raise RequiredArgument( function=cls.modify_policy_set_nvt_preference.__name__, argument="nvt_oid", ) if not name: raise RequiredArgument( function=cls.modify_policy_set_nvt_preference.__name__, argument="name", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) xml_pref = cmd.add_element("preference") xml_pref.add_element("nvt", attrs={"oid": nvt_oid}) xml_pref.add_element("name", name) if value: xml_pref.add_element("value", to_base64(value)) return cmd @classmethod def modify_policy_set_name(cls, policy_id: EntityID, name: str) -> Request: """Modifies the name of an existing policy Args: policy_id: UUID of policy to modify. name: New name for the policy. """ if not policy_id: raise RequiredArgument( function=cls.modify_policy_set_name.__name__, argument="policy_id", ) if not name: raise RequiredArgument( function=cls.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 cmd @classmethod def modify_policy_set_comment( cls, policy_id: EntityID, comment: Optional[str] = None ) -> Request: """Modifies the comment of an existing policy Args: 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=cls.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 cmd @classmethod def modify_policy_set_scanner_preference( cls, policy_id: EntityID, name: str, *, value: Optional[str] = None ) -> Request: """Modifies the scanner preferences of an existing policy Args: 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=cls.modify_policy_set_scanner_preference.__name__, argument="policy_id", ) if not name: raise RequiredArgument( function=cls.modify_policy_set_scanner_preference.__name__, argument="name argument", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) xml_pref = cmd.add_element("preference") xml_pref.add_element("name", name) if value: xml_pref.add_element("value", to_base64(value)) return cmd @classmethod def modify_policy_set_nvt_selection( cls, policy_id: EntityID, family: str, nvt_oids: Sequence[str] ) -> Request: """Modifies the selected nvts of an existing policy The manager updates the given family in the policy to include only the given NVTs. Args: 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=cls.modify_policy_set_nvt_selection.__name__, argument="policy_id", ) if not family: raise RequiredArgument( function=cls.modify_policy_set_nvt_selection.__name__, argument="family", ) if nvt_oids is None: raise RequiredArgument( function=cls.modify_policy_set_nvt_selection.__name__, argument="nvt_oids", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) xml_nvt_selection = cmd.add_element("nvt_selection") xml_nvt_selection.add_element("family", family) for nvt in nvt_oids: xml_nvt_selection.add_element("nvt", attrs={"oid": str(nvt)}) return cmd @classmethod def modify_policy_set_family_selection( cls, policy_id: EntityID, families: Sequence[tuple[str, bool, bool]], *, auto_add_new_families: Optional[bool] = True, ) -> Request: """ Selected the NVTs of a policy at a family level. Args: 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=cls.modify_policy_set_family_selection.__name__, argument="policy_id", ) if families is None: raise RequiredArgument( function=cls.modify_policy_set_family_selection.__name__, argument="families", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(policy_id)) xml_family_selection = cmd.add_element("family_selection") xml_family_selection.add_element( "growing", to_bool(auto_add_new_families) ) for family in families: xml_family = xml_family_selection.add_element("family") if len(family) != 3: raise InvalidArgument( "Family must be a tuple of 3. (str, bool, bool)" ) xml_family.add_element("name", family[0]) xml_family.add_element("all", to_bool(family[2])) xml_family.add_element("growing", to_bool(family[1])) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_port_lists.py000066400000000000000000000160621466406635600246250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class PortRangeType(Enum): """Enum for port range type""" TCP = "TCP" UDP = "UDP" class PortLists: @classmethod def clone_port_list(cls, port_list_id: EntityID) -> Request: """Clone an existing port list Args: port_list_id: UUID of an existing port list to clone from """ if not port_list_id: raise RequiredArgument( function=cls.clone_port_list.__name__, argument="port_list_id" ) cmd = XmlCommand("create_port_list") cmd.add_element("copy", str(port_list_id)) return cmd @classmethod def create_port_list( cls, name: str, port_range: str, *, comment: Optional[str] = None ) -> Request: """Create a new port list Args: 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 """ if not name: raise RequiredArgument( function=cls.create_port_list.__name__, argument="name" ) if not port_range: raise RequiredArgument( function=cls.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 cmd @classmethod def create_port_range( cls, port_list_id: EntityID, start: int, end: int, port_range_type: Union[str, PortRangeType], *, comment: Optional[str] = None, ) -> Request: """Create new port range Args: 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 """ if not port_list_id: raise RequiredArgument( function=cls.create_port_range.__name__, argument="port_list_id", ) if not port_range_type: raise RequiredArgument( function=cls.create_port_range.__name__, argument="port_range_type", ) if not start: raise RequiredArgument( function=cls.create_port_range.__name__, argument="start" ) if not end: raise RequiredArgument( function=cls.create_port_range.__name__, argument="end" ) if not isinstance(port_range_type, PortRangeType): port_range_type = PortRangeType(port_range_type) cmd = XmlCommand("create_port_range") cmd.add_element("port_list", attrs={"id": str(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 cmd @classmethod def delete_port_list( cls, port_list_id: EntityID, *, ultimate: bool = False ) -> Request: """Deletes an existing port list Args: 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=cls.delete_port_list.__name__, argument="port_list_id" ) cmd = XmlCommand("delete_port_list") cmd.set_attribute("port_list_id", str(port_list_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @classmethod def delete_port_range(cls, port_range_id: EntityID) -> Request: """Deletes an existing port range Args: port_range_id: UUID of the port range to be deleted. """ if not port_range_id: raise RequiredArgument( function=cls.delete_port_range.__name__, argument="port_range_id", ) cmd = XmlCommand("delete_port_range") cmd.set_attribute("port_range_id", str(port_range_id)) return cmd @classmethod def get_port_lists( cls, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, details: Optional[bool] = None, targets: Optional[bool] = None, trash: Optional[bool] = None, ) -> Request: """Request a list of port lists Args: 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 """ cmd = XmlCommand("get_port_lists") cmd.add_filter(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 cmd @classmethod def get_port_list(cls, port_list_id: EntityID) -> Request: """Request a single port list Args: port_list_id: UUID of an existing port list """ cmd = XmlCommand("get_port_lists") if not port_list_id: raise RequiredArgument( function=cls.get_port_list.__name__, argument="port_list_id" ) cmd.set_attribute("port_list_id", str(port_list_id)) # for single entity always request all details cmd.set_attribute("details", "1") return cmd @classmethod def modify_port_list( cls, port_list_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, ) -> Request: """Modifies an existing port list. Args: port_list_id: UUID of port list to modify. name: Name of port list. comment: Comment on port list. """ if not port_list_id: raise RequiredArgument( function=cls.modify_port_list.__name__, argument="port_list_id" ) cmd = XmlCommand("modify_port_list") cmd.set_attribute("port_list_id", str(port_list_id)) if comment: cmd.add_element("comment", comment) if name: cmd.add_element("name", name) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_report_formats.py000066400000000000000000000203311466406635600254630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from typing import Optional, Union from gvm._enum import Enum from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand, XmlError from .._entity_id import EntityID 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" def __str__(self) -> str: return self.value class ReportFormats: @classmethod def clone_report_format( cls, report_format_id: Union[EntityID, ReportFormatType] ) -> Request: """Clone a report format from an existing one Args: report_format_id: UUID of the existing report format or ReportFormatType (enum) """ if not report_format_id: raise RequiredArgument( function=cls.clone_report_format.__name__, argument="report_format_id", ) cmd = XmlCommand("create_report_format") cmd.add_element("copy", str(report_format_id)) return cmd @classmethod def delete_report_format( cls, report_format_id: Union[EntityID, ReportFormatType], *, ultimate: Optional[bool] = False, ) -> Request: """Deletes an existing report format Args: 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=cls.delete_report_format.__name__, argument="report_format_id", ) cmd = XmlCommand("delete_report_format") cmd.set_attribute("report_format_id", str(report_format_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_report_formats( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, alerts: Optional[bool] = None, params: Optional[bool] = None, details: Optional[bool] = None, ) -> Request: """Request a list of report formats Args: 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 """ cmd = XmlCommand("get_report_formats") cmd.add_filter(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 cmd @classmethod def get_report_format( cls, report_format_id: Union[EntityID, ReportFormatType] ) -> Request: """Request a single report format Args: report_format_id: UUID of an existing report format or ReportFormatType (enum) """ if not report_format_id: raise RequiredArgument( function=cls.get_report_format.__name__, argument="report_format_id", ) cmd = XmlCommand("get_report_formats") cmd.set_attribute("report_format_id", str(report_format_id)) # for single entity always request all details cmd.set_attribute("details", "1") return cmd @classmethod def import_report_format(cls, report_format: str) -> Request: """Import a report format from XML Args: report_format: Report format XML as string to import. This XML must contain a :code:`` root element. """ if not report_format: raise RequiredArgument( function=cls.import_report_format.__name__, argument="report_format", ) cmd = XmlCommand("create_report_format") try: cmd.append_xml_str(report_format) except XmlError as e: raise InvalidArgument( function=cls.import_report_format.__name__, argument="report_format", ) from e return cmd @classmethod def modify_report_format( cls, report_format_id: Union[EntityID, ReportFormatType], *, active: Optional[bool] = None, name: Optional[str] = None, summary: Optional[str] = None, param_name: Optional[str] = None, param_value: Optional[str] = None, ) -> Request: """Modifies an existing report format. Args: 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. """ if not report_format_id: raise RequiredArgument( function=cls.modify_report_format.__name__, argument="report_format_id ", ) cmd = XmlCommand("modify_report_format") cmd.set_attribute("report_format_id", str(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: xml_param = cmd.add_element("param") xml_param.add_element("name", param_name) if param_value is not None: xml_param.add_element("value", param_value) return cmd @classmethod def verify_report_format( cls, report_format_id: Union[EntityID, ReportFormatType] ) -> Request: """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. Args: report_format_id: UUID of the report format to be verified or ReportFormatType (enum) """ if not report_format_id: raise RequiredArgument( function=cls.verify_report_format.__name__, argument="report_format_id", ) cmd = XmlCommand("verify_report_format") cmd.set_attribute("report_format_id", str(report_format_id)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_reports.py000066400000000000000000000124161466406635600241200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand, XmlError from .._entity_id import EntityID from ._report_formats import ReportFormatType class Reports: @classmethod def delete_report(cls, report_id: EntityID) -> Request: """Deletes an existing report Args: report_id: UUID of the report to be deleted. """ if not report_id: raise RequiredArgument( function=cls.delete_report.__name__, argument="report_id" ) cmd = XmlCommand("delete_report") cmd.set_attribute("report_id", str(report_id)) return cmd @classmethod def get_report( cls, report_id: EntityID, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, delta_report_id: Optional[EntityID] = None, report_format_id: Optional[Union[str, ReportFormatType]] = None, ignore_pagination: Optional[bool] = None, details: Optional[bool] = True, ) -> Request: """Request a single report Args: 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 """ cmd = XmlCommand("get_reports") if not report_id: raise RequiredArgument( function=cls.get_report.__name__, argument="report_id" ) cmd.set_attribute("report_id", str(report_id)) cmd.add_filter(filter_string, filter_id) if delta_report_id: cmd.set_attribute("delta_report_id", str(delta_report_id)) if report_format_id: cmd.set_attribute("format_id", str(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 cmd @staticmethod def get_reports( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, note_details: Optional[bool] = None, override_details: Optional[bool] = None, ignore_pagination: Optional[bool] = None, details: Optional[bool] = None, ) -> Request: """Request a list of reports Args: 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 ignore_pagination: Whether to ignore the filter terms "first" and "rows". details: Whether to exclude results """ cmd = XmlCommand("get_reports") if filter_string: cmd.set_attribute("report_filter", filter_string) if filter_id: cmd.set_attribute("report_filt_id", str(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)) if ignore_pagination is not None: cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination)) return cmd @classmethod def import_report( cls, report: str, task_id: EntityID, *, in_assets: Optional[bool] = None, ) -> Request: """Import a Report from XML Args: 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 """ if not report: raise RequiredArgument( function=cls.import_report.__name__, argument="report" ) cmd = XmlCommand("create_report") if not task_id: raise RequiredArgument( function=cls.import_report.__name__, argument="task_id" ) cmd.add_element("task", attrs={"id": str(task_id)}) if in_assets is not None: cmd.add_element("in_assets", to_bool(in_assets)) try: cmd.append_xml_str(report) except XmlError as e: raise InvalidArgument( f"Invalid xml passed as report to import_report {e}" ) from None return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_results.py000066400000000000000000000042431466406635600241220ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class Results: @classmethod def get_result(cls, result_id: EntityID) -> Request: """Request a single result Args: result_id: UUID of an existing result """ cmd = XmlCommand("get_results") if not result_id: raise RequiredArgument( function=cls.get_result.__name__, argument="result_id" ) cmd.set_attribute("result_id", str(result_id)) # for single entity always request all details cmd.set_attribute("details", "1") return cmd @staticmethod def get_results( *, 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, ) -> Request: """Request a list of results Args: 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 """ cmd = XmlCommand("get_results") cmd.add_filter(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 cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_roles.py000066400000000000000000000100351466406635600235410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool, to_comma_list from gvm.xml import XmlCommand from .._entity_id import EntityID class Roles: @classmethod def clone_role(cls, role_id: EntityID) -> Request: """Clone an existing role Args: role_id: UUID of an existing role to clone from """ if not role_id: raise RequiredArgument( function=cls.clone_role.__name__, argument="role_id" ) cmd = XmlCommand("create_role") cmd.add_element("copy", str(role_id)) return cmd @classmethod def create_role( cls, name: str, *, comment: Optional[str] = None, users: Optional[list[str]] = None, ) -> Request: """Create a new role Args: name: Name of the role comment: Comment for the role users: List of user names to add to the role """ if not name: raise RequiredArgument( function=cls.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 cmd @classmethod def delete_role( cls, role_id: str, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing role Args: 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=cls.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 cmd @staticmethod def get_roles( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, ) -> Request: """Request a list of roles Args: 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 """ cmd = XmlCommand("get_roles") cmd.add_filter(filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return cmd @classmethod def get_role(cls, role_id: EntityID) -> Request: """Request a single role Args: role_id: UUID of an existing role """ if not role_id: raise RequiredArgument( function=cls.get_role.__name__, argument="role_id" ) cmd = XmlCommand("get_roles") cmd.set_attribute("role_id", str(role_id)) return cmd @classmethod def modify_role( cls, role_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, users: Optional[list[str]] = None, ) -> Request: """Modifies an existing role. Args: role_id: UUID of role to modify. comment: Name of role. name: Comment on role. users: List of user names. """ if not role_id: raise RequiredArgument( function=cls.modify_role.__name__, argument="role_id argument" ) cmd = XmlCommand("modify_role") cmd.set_attribute("role_id", str(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 cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_scan_configs.py000066400000000000000000000366371466406635600250710ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.protocols.core import Request from gvm.utils import is_list_like, to_base64, to_bool from gvm.xml import XmlCommand, XmlError from .._entity_id import EntityID class ScanConfigs: @classmethod def clone_scan_config(cls, config_id: EntityID) -> Request: """Clone a scan config from an existing one Args: config_id: UUID of the existing scan config """ if not config_id: raise RequiredArgument( function=cls.clone_scan_config.__name__, argument="config_id" ) cmd = XmlCommand("create_config") cmd.add_element("copy", str(config_id)) return cmd @classmethod def create_scan_config( cls, config_id: EntityID, name: str, *, comment: Optional[str] = None, ) -> Request: """Create a new scan config Args: config_id: UUID of the existing scan config name: Name of the new scan config comment: A comment on the config """ if not name: raise RequiredArgument( function=cls.create_scan_config.__name__, argument="name" ) if not config_id: raise RequiredArgument( function=cls.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", str(config_id)) cmd.add_element("name", name) cmd.add_element("usage_type", "scan") return cmd @classmethod def delete_scan_config( cls, config_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing config Args: 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=cls.delete_scan_config.__name__, argument="config_id" ) cmd = XmlCommand("delete_config") cmd.set_attribute("config_id", str(config_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_scan_configs( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, details: Optional[bool] = None, families: Optional[bool] = None, preferences: Optional[bool] = None, tasks: Optional[bool] = None, ) -> Request: """Request a list of scan configs Args: 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 """ cmd = XmlCommand("get_configs") cmd.set_attribute("usage_type", "scan") cmd.add_filter(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 cmd @classmethod def get_scan_config( cls, config_id: EntityID, *, tasks: Optional[bool] = None ) -> Request: """Request a single scan config Args: config_id: UUID of an existing scan config tasks: Whether to get tasks using this config """ if not config_id: raise RequiredArgument( function=cls.get_scan_config.__name__, argument="config_id" ) cmd = XmlCommand("get_configs") cmd.set_attribute("config_id", str(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 cmd @classmethod def get_scan_config_preferences( cls, *, nvt_oid: Optional[str] = None, config_id: Optional[EntityID] = None, ) -> Request: """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. Args: nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values """ cmd = XmlCommand("get_preferences") if nvt_oid: cmd.set_attribute("nvt_oid", str(nvt_oid)) if config_id: cmd.set_attribute("config_id", str(config_id)) return cmd @classmethod def get_scan_config_preference( cls, name: str, *, nvt_oid: Optional[str] = None, config_id: Optional[EntityID] = None, ) -> Request: """Request a nvt preference Args: name: name of a particular preference nvt_oid: OID of nvt config_id: UUID of scan config of which to show preference values """ cmd = XmlCommand("get_preferences") if not name: raise RequiredArgument( function=cls.get_scan_config_preference.__name__, argument="name", ) cmd.set_attribute("preference", name) if nvt_oid: cmd.set_attribute("nvt_oid", str(nvt_oid)) if config_id: cmd.set_attribute("config_id", str(config_id)) return cmd @classmethod def import_scan_config(cls, config: str) -> Request: """Import a scan config from XML Args: config: Scan Config XML as string to import. This XML must contain a :code:`` root element. """ if not config: raise RequiredArgument( function=cls.import_scan_config.__name__, argument="config" ) cmd = XmlCommand("create_config") try: cmd.append_xml_str(config) except XmlError as e: raise InvalidArgument( function=cls.import_scan_config.__name__, argument="config" ) from e return cmd @classmethod def modify_scan_config_set_nvt_preference( cls, config_id: EntityID, name: str, nvt_oid: str, *, value: Optional[str] = None, ) -> Request: """Modifies the nvt preferences of an existing scan config. Args: 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=cls.modify_scan_config_set_nvt_preference.__name__, argument="config_id", ) if not nvt_oid: raise RequiredArgument( function=cls.modify_scan_config_set_nvt_preference.__name__, argument="nvt_oid", ) if not name: raise RequiredArgument( function=cls.modify_scan_config_set_nvt_preference.__name__, argument="name", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) xml_preference = cmd.add_element("preference") xml_preference.add_element("nvt", attrs={"oid": str(nvt_oid)}) xml_preference.add_element("name", name) if value: xml_preference.add_element("value", to_base64(value)) return cmd @classmethod def modify_scan_config_set_name( cls, config_id: EntityID, name: str ) -> Request: """Modifies the name of an existing scan config Args: config_id: UUID of scan config to modify. name: New name for the config. """ if not config_id: raise RequiredArgument( function=cls.modify_scan_config_set_name.__name__, argument="config_id", ) if not name: raise RequiredArgument( function=cls.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 cmd @classmethod def modify_scan_config_set_comment( cls, config_id: EntityID, *, comment: Optional[str] = None ) -> Request: """Modifies the comment of an existing scan config Args: 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=cls.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 cmd @classmethod def modify_scan_config_set_scanner_preference( cls, config_id: EntityID, name: str, *, value: Optional[str] = None, ) -> Request: """Modifies the scanner preferences of an existing scan config Args: 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=( cls.modify_scan_config_set_scanner_preference.__name__ ), argument="config_id", ) if not name: raise RequiredArgument( function=( cls.modify_scan_config_set_scanner_preference.__name__ ), argument="name argument", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) xml_preference = cmd.add_element("preference") xml_preference.add_element("name", name) if value: xml_preference.add_element("value", to_base64(value)) return cmd @classmethod def modify_scan_config_set_nvt_selection( cls, config_id: EntityID, family: str, nvt_oids: Union[tuple[str], list[str]], ) -> Request: """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=cls.modify_scan_config_set_nvt_selection.__name__, argument="config_id", ) if not family: raise RequiredArgument( function=cls.modify_scan_config_set_nvt_selection.__name__, argument="family argument", ) if not is_list_like(nvt_oids): raise InvalidArgumentType( function=cls.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 cmd @classmethod def modify_scan_config_set_family_selection( cls, config_id: EntityID, families: list[tuple[str, bool, bool]], *, auto_add_new_families: Optional[bool] = True, ) -> Request: """ Selected the NVTs of a scan config at a family level. Args: 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=cls.modify_scan_config_set_family_selection.__name__, argument="config_id", ) if not is_list_like(families): raise InvalidArgumentType( function=cls.modify_scan_config_set_family_selection.__name__, argument="families", arg_type="list", ) cmd = XmlCommand("modify_config") cmd.set_attribute("config_id", str(config_id)) xml_family_selection = cmd.add_element("family_selection") xml_family_selection.add_element( "growing", to_bool(auto_add_new_families) ) for family in families: xml_family = xml_family_selection.add_element("family") xml_family.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=( cls.modify_scan_config_set_family_selection.__name__ ), argument="families", arg_type="[tuple(str, bool, bool)]", ) xml_family.add_element("all", to_bool(family[2])) xml_family.add_element("growing", to_bool(family[1])) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_scanners.py000066400000000000000000000211251466406635600242330ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class ScannerType(Enum): """Enum for scanner type""" # 1 was removed (OSP_SCANNER_TYPE). 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.OPENVAS_SCANNER_TYPE.value or scanner_type == "openvas" or scanner_type == "openvas_scanner_type" ): return cls.OPENVAS_SCANNER_TYPE if ( scanner_type == cls.CVE_SCANNER_TYPE.value or scanner_type == "cve" or scanner_type == "cve_scanner_type" ): return cls.CVE_SCANNER_TYPE if ( scanner_type == cls.GREENBONE_SENSOR_SCANNER_TYPE.value or scanner_type == "greenbone" or scanner_type == "greenbone_sensor_scanner_type" ): return cls.GREENBONE_SENSOR_SCANNER_TYPE raise InvalidArgument( argument="scanner_type", function=cls.from_string.__name__ ) class Scanners: @classmethod def create_scanner( cls, name: str, host: str, port: Union[str, int], scanner_type: ScannerType, credential_id: str, *, ca_pub: Optional[str] = None, comment: Optional[str] = None, ) -> Request: """Create a new scanner Args: name: Name of the new scanner host: Hostname or IP address of the scanner port: 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 """ if not name: raise RequiredArgument( function=cls.create_scanner.__name__, argument="name" ) if not host: raise RequiredArgument( function=cls.create_scanner.__name__, argument="host" ) if not port: raise RequiredArgument( function=cls.create_scanner.__name__, argument="port" ) if not scanner_type: raise RequiredArgument( function=cls.create_scanner.__name__, argument="scanner_type" ) if not credential_id: raise RequiredArgument( function=cls.create_scanner.__name__, argument="credential_id" ) cmd = XmlCommand("create_scanner") cmd.add_element("name", name) cmd.add_element("host", host) cmd.add_element("port", str(port)) if not isinstance(scanner_type, ScannerType): scanner_type = ScannerType(scanner_type) cmd.add_element("type", scanner_type.value) cmd.add_element("credential", attrs={"id": str(credential_id)}) if ca_pub: cmd.add_element("ca_pub", ca_pub) if comment: cmd.add_element("comment", comment) return cmd @classmethod def modify_scanner( cls, scanner_id: EntityID, *, name: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None, scanner_type: Optional[ScannerType] = None, credential_id: Optional[EntityID] = None, ca_pub: Optional[str] = None, comment: Optional[str] = None, ) -> Request: """Modify an existing scanner Args: scanner_id: UUID of the scanner to modify name: New name of the scanner host: New hostname or IP address of the scanner port: New port of the scanner scanner_type: New type of the scanner credential_id: New UUID of client certificate credential for the scanner ca_pub: New certificate of CA to verify scanner certificate comment: New comment for the scanner """ if not scanner_id: raise RequiredArgument( function=cls.modify_scanner.__name__, argument="scanner_id" ) cmd = XmlCommand("modify_scanner") cmd.set_attribute("scanner_id", str(scanner_id)) if scanner_type is not None: if not isinstance(scanner_type, ScannerType): scanner_type = ScannerType(scanner_type) if not scanner_type: raise InvalidArgument( argument="scanner_type", function=cls.modify_scanner.__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 cmd @staticmethod def get_scanners( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, details: Optional[bool] = None, ) -> Request: """Request a list of scanners Args: 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 """ cmd = XmlCommand("get_scanners") cmd.add_filter(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 cmd @classmethod def get_scanner(cls, scanner_id: EntityID) -> Request: """Request a single scanner Args: scanner_id: UUID of an existing scanner """ if not scanner_id: raise RequiredArgument( function=cls.get_scanner.__name__, argument="scanner_id" ) cmd = XmlCommand("get_scanners") cmd.set_attribute("scanner_id", str(scanner_id)) # for single entity always request all details cmd.set_attribute("details", "1") return cmd @classmethod def verify_scanner(cls, scanner_id: EntityID) -> Request: """Verify an existing scanner Args: scanner_id: UUID of an existing scanner """ if not scanner_id: raise RequiredArgument( function=cls.verify_scanner.__name__, argument="scanner_id" ) cmd = XmlCommand("verify_scanner") cmd.set_attribute("scanner_id", str(scanner_id)) return cmd @classmethod def clone_scanner(cls, scanner_id: EntityID) -> Request: """Clone an existing scanner Args: scanner_id: UUID of an existing scanner """ if not scanner_id: raise RequiredArgument( function=cls.clone_scanner.__name__, argument="scanner_id" ) cmd = XmlCommand("create_scanner") cmd.add_element("copy", str(scanner_id)) return cmd @classmethod def delete_scanner( cls, scanner_id: EntityID, ultimate: Optional[bool] = False ) -> Request: """Delete an existing scanner Args: scanner_id: UUID of an existing scanner """ if not scanner_id: raise RequiredArgument( function=cls.delete_scanner.__name__, argument="scanner_id" ) cmd = XmlCommand("delete_scanner") cmd.set_attribute("scanner_id", str(scanner_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_schedules.py000066400000000000000000000152171466406635600244030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class Schedules: @classmethod def clone_schedule(cls, schedule_id: EntityID) -> Request: """Clone an existing schedule Args: schedule_id: UUID of an existing schedule to clone from """ if not schedule_id: raise RequiredArgument( function=cls.clone_schedule.__name__, argument="schedule_id" ) cmd = XmlCommand("create_schedule") cmd.add_element("copy", str(schedule_id)) return cmd @classmethod def create_schedule( cls, name: str, icalendar: str, timezone: str, *, comment: Optional[str] = None, ) -> Request: """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) Schedules.create_schedule( name="My Schedule", icalendar=cal.to_ical(), timezone='UTC' ) Args: name: Name of the new schedule icalendar: `iCalendar`_ (RFC 5545) based data. timezone: Timezone to use for the icalendar 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. .. _iCalendar: https://tools.ietf.org/html/rfc5545 """ if not name: raise RequiredArgument( function=cls.create_schedule.__name__, argument="name" ) if not icalendar: raise RequiredArgument( function=cls.create_schedule.__name__, argument="icalendar" ) if not timezone: raise RequiredArgument( function=cls.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 cmd @classmethod def delete_schedule( cls, schedule_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing schedule Args: 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=cls.delete_schedule.__name__, argument="schedule_id" ) cmd = XmlCommand("delete_schedule") cmd.set_attribute("schedule_id", str(schedule_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_schedules( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> Request: """Request a list of schedules Args: 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 """ cmd = XmlCommand("get_schedules") cmd.add_filter(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 cmd @classmethod def get_schedule( cls, schedule_id: EntityID, *, tasks: Optional[bool] = None ) -> Request: """Request a single schedule Args: schedule_id: UUID of an existing schedule tasks: Whether to include tasks using the schedules """ cmd = XmlCommand("get_schedules") if not schedule_id: raise RequiredArgument( function=cls.get_schedule.__name__, argument="schedule_id" ) cmd.set_attribute("schedule_id", str(schedule_id)) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return cmd @classmethod def modify_schedule( cls, schedule_id: EntityID, *, name: Optional[str] = None, icalendar: Optional[str] = None, timezone: Optional[str] = None, comment: Optional[str] = None, ) -> Request: """Modifies an existing schedule Args: 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 icalendar 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. .. _iCalendar: https://tools.ietf.org/html/rfc5545 """ if not schedule_id: raise RequiredArgument( function=cls.modify_schedule.__name__, argument="schedule_id" ) cmd = XmlCommand("modify_schedule") cmd.set_attribute("schedule_id", str(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 cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_secinfo.py000066400000000000000000000053761466406635600240570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID 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" class SecInfo: @classmethod def get_info(cls, info_id: EntityID, info_type: InfoType) -> Request: """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 """ if not info_type: raise RequiredArgument( function=cls.get_info.__name__, argument="info_type" ) if not isinstance(info_type, InfoType): info_type = InfoType(info_type) if not info_id: raise RequiredArgument( function=cls.get_info.__name__, argument="info_id" ) cmd = XmlCommand("get_info") cmd.set_attribute("info_id", str(info_id)) cmd.set_attribute("type", info_type.value) # for single entity always request all details cmd.set_attribute("details", "1") return cmd @classmethod def get_info_list( cls, info_type: InfoType, *, filter_string: Optional[str] = None, filter_id: Optional[str] = None, name: Optional[str] = None, details: Optional[bool] = None, ) -> Request: """Request a list of security information Args: info_type: Type must be either CERT_BUND_ADV, CPE, CVE, DFN_CERT_ADV, OVALDEF or NVT 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 """ if not info_type: raise RequiredArgument( function=cls.get_info_list.__name__, argument="info_type" ) if not isinstance(info_type, InfoType): info_type = InfoType(info_type) cmd = XmlCommand("get_info") cmd.set_attribute("type", info_type.value) cmd.add_filter(filter_string, filter_id) if name: cmd.set_attribute("name", name) if details is not None: cmd.set_attribute("details", to_bool(details)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_severity.py000066400000000000000000000005311466406635600242670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from numbers import Real from gvm._enum import Enum Severity = Real class SeverityLevel(Enum): """Enum for severity levels""" HIGH = "High" MEDIUM = "Medium" LOW = "Low" LOG = "Log" ALARM = "Alarm" DEBUG = "Debug" python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_system_reports.py000066400000000000000000000040651466406635600255250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from numbers import Integral from typing import Optional from gvm.errors import InvalidArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class SystemReports: @classmethod def get_system_reports( cls, *, 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[EntityID] = None, ) -> Request: """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 """ 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", function=cls.get_system_reports.__name__, ) 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", str(slave_id)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_tags.py000066400000000000000000000203071466406635600233560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID from ._entity_type import EntityType class Tags: @classmethod def clone_tag(cls, tag_id: EntityID) -> Request: """Clone an existing tag Args: tag_id: UUID of an existing tag to clone from """ if not tag_id: raise RequiredArgument( function=cls.clone_tag.__name__, argument="tag_id" ) cmd = XmlCommand("create_tag") cmd.add_element("copy", str(tag_id)) return cmd @classmethod def create_tag( cls, name: str, resource_type: EntityType, *, resource_filter: Optional[str] = None, resource_ids: Optional[list[EntityID]] = None, value: Optional[str] = None, comment: Optional[str] = None, active: Optional[bool] = None, ) -> Request: """Create a tag Args: 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. """ if not name: raise RequiredArgument( function=cls.create_tag.__name__, argument="name" ) if resource_filter and resource_ids: raise InvalidArgument( "create_tag accepts either resource_filter or resource_ids " "argument", function=cls.create_tag.__name__, ) if not resource_type: raise RequiredArgument( function=cls.create_tag.__name__, argument="resource_type" ) if not isinstance(resource_type, EntityType): resource_type = EntityType(resource_type) cmd = XmlCommand("create_tag") cmd.add_element("name", name) xml_resources = cmd.add_element("resources") if resource_filter is not None: xml_resources.set_attribute("filter", resource_filter) for resource_id in resource_ids or []: xml_resources.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 xml_resources.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: cmd.add_element("active", to_bool(active)) return cmd @classmethod def delete_tag( cls, tag_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing tag Args: 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=cls.delete_tag.__name__, argument="tag_id" ) cmd = XmlCommand("delete_tag") cmd.set_attribute("tag_id", str(tag_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_tags( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, names_only: Optional[bool] = None, ) -> Request: """Request a list of tags Args: 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 """ cmd = XmlCommand("get_tags") cmd.add_filter(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 cmd @classmethod def get_tag(cls, tag_id: EntityID) -> Request: """Request a single tag Args: tag_id: UUID of an existing tag """ cmd = XmlCommand("get_tags") if not tag_id: raise RequiredArgument( function=cls.get_tag.__name__, argument="tag_id" ) cmd.set_attribute("tag_id", str(tag_id)) return cmd @classmethod def modify_tag( cls, tag_id: EntityID, *, comment: Optional[str] = None, name: Optional[str] = None, value: Optional[str] = None, active: Optional[bool] = None, resource_action: Optional[str] = None, resource_type: Optional[EntityType] = None, resource_filter: Optional[str] = None, resource_ids: Optional[list[EntityID]] = None, ) -> Request: """Modifies an existing tag. Args: 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. """ if not tag_id: raise RequiredArgument( function=cls.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=cls.modify_tag.__name__, argument="resource_type" ) xml_resources = cmd.add_element("resources") if resource_action is not None: xml_resources.set_attribute("action", resource_action) if resource_filter is not None: xml_resources.set_attribute("filter", resource_filter) for resource_id in resource_ids or []: xml_resources.add_element( "resource", attrs={"id": str(resource_id)} ) if resource_type is not None: if not isinstance(resource_type, EntityType): resource_type = EntityType(resource_type) 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 xml_resources.add_element("type", actual_resource_type.value) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_targets.py000066400000000000000000000306571466406635600241020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool, to_comma_list from gvm.xml import XmlCommand from .._entity_id import EntityID 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 Targets: @classmethod def create_target( cls, 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[EntityID] = None, ssh_credential_port: Optional[Union[int, str]] = None, smb_credential_id: Optional[EntityID] = None, esxi_credential_id: Optional[EntityID] = None, snmp_credential_id: Optional[EntityID] = None, alive_test: Optional[Union[str, 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[EntityID] = None, ) -> Request: """Create a new target Args: 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 """ if not name: raise RequiredArgument( function=cls.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=cls.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: xml_ssh = cmd.add_element( "ssh_credential", attrs={"id": str(ssh_credential_id)} ) if ssh_credential_port: xml_ssh.add_element("port", str(ssh_credential_port)) if smb_credential_id: cmd.add_element( "smb_credential", attrs={"id": str(smb_credential_id)} ) if esxi_credential_id: cmd.add_element( "esxi_credential", attrs={"id": str(esxi_credential_id)} ) if snmp_credential_id: cmd.add_element( "snmp_credential", attrs={"id": str(snmp_credential_id)} ) if alive_test: if not isinstance(alive_test, AliveTest): alive_test = AliveTest(alive_test) 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": str(port_list_id)}) return cmd @classmethod def modify_target( cls, target_id: EntityID, *, name: Optional[str] = None, comment: Optional[str] = None, hosts: Optional[list[str]] = None, exclude_hosts: Optional[list[str]] = None, ssh_credential_id: Optional[EntityID] = None, ssh_credential_port: Optional[Union[str, int]] = None, smb_credential_id: Optional[EntityID] = None, esxi_credential_id: Optional[EntityID] = None, snmp_credential_id: Optional[EntityID] = None, alive_test: Optional[Union[AliveTest, str]] = None, allow_simultaneous_ips: Optional[bool] = None, reverse_lookup_only: Optional[bool] = None, reverse_lookup_unify: Optional[bool] = None, port_list_id: Optional[EntityID] = None, ) -> Request: """Modify an existing target. Args: target_id: UUID 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. """ if not target_id: raise RequiredArgument( function=cls.modify_target.__name__, argument="target_id" ) cmd = XmlCommand("modify_target") cmd.set_attribute("target_id", str(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): alive_test = AliveTest(alive_test) cmd.add_element("alive_tests", alive_test.value) if ssh_credential_id: xml_ssh = cmd.add_element( "ssh_credential", attrs={"id": str(ssh_credential_id)} ) if ssh_credential_port: xml_ssh.add_element("port", str(ssh_credential_port)) if smb_credential_id: cmd.add_element( "smb_credential", attrs={"id": str(smb_credential_id)} ) if esxi_credential_id: cmd.add_element( "esxi_credential", attrs={"id": str(esxi_credential_id)} ) if snmp_credential_id: cmd.add_element( "snmp_credential", attrs={"id": str(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": str(port_list_id)}) return cmd @classmethod def clone_target(cls, target_id: EntityID) -> Request: """Clone an existing target. Args: target_id: UUID of an existing target to clone. """ if not target_id: raise RequiredArgument( function=cls.clone_target.__name__, argument="target_id" ) cmd = XmlCommand("create_target") cmd.add_element("copy", str(target_id)) return cmd @classmethod def delete_target( cls, target_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Delete an existing target. Args: target_id: UUID of an existing target to delete. ultimate: Whether to remove entirely or to the trashcan. """ if not target_id: raise RequiredArgument( function=cls.delete_target.__name__, argument="target_id" ) cmd = XmlCommand("delete_target") cmd.set_attribute("target_id", str(target_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @classmethod def get_target( cls, target_id: EntityID, *, tasks: Optional[bool] = None ) -> Request: """Request a single target. Args: target_id: UUID of the target to request. tasks: Whether to include list of tasks that use the target """ if not target_id: raise RequiredArgument( function=cls.get_target.__name__, argument="target_id" ) cmd = XmlCommand("get_targets") cmd.set_attribute("target_id", str(target_id)) if tasks is not None: cmd.set_attribute("tasks", to_bool(tasks)) return cmd @classmethod def get_targets( cls, *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, tasks: Optional[bool] = None, ) -> Request: """Request a list of targets. Args: filter_string: Filter term to use for the query. filter_id: UUID of an existing filter to use for the query. trash: Whether to include targets in the trashcan. tasks: Whether to include list of tasks that use the target. """ cmd = XmlCommand("get_targets") cmd.add_filter(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 cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_tasks.py000066400000000000000000000340371466406635600235520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from numbers import Integral from typing import Mapping, Optional, Sequence from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.utils import SupportsStr, to_bool, to_comma_list from gvm.xml import XmlCommand from .._entity_id import EntityID from ._hosts import HostsOrdering class Tasks: @classmethod def clone_task(cls, task_id: EntityID) -> Request: """Clone an existing task Args: task_id: UUID of existing task to clone from """ if not task_id: raise RequiredArgument( function=cls.clone_task.__name__, argument="task_id" ) cmd = XmlCommand("create_task") cmd.add_element("copy", str(task_id)) return cmd @classmethod def create_container_task( cls, name: str, *, comment: Optional[str] = None ) -> Request: """Create a new container task A container task is a "meta" task to import and view reports from other systems. Args: name: Name of the task comment: Comment for the task """ if not name: raise RequiredArgument( function=cls.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 cmd @classmethod def create_task( cls, name: str, config_id: EntityID, target_id: EntityID, scanner_id: EntityID, *, alterable: Optional[bool] = None, hosts_ordering: Optional[HostsOrdering] = None, schedule_id: Optional[EntityID] = None, alert_ids: Optional[Sequence[EntityID]] = None, comment: Optional[str] = None, schedule_periods: Optional[int] = None, observers: Optional[Sequence[str]] = None, preferences: Optional[Mapping[str, SupportsStr]] = None, ) -> Request: """Create a new scan task Args: 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. """ if not name: raise RequiredArgument( function=cls.create_task.__name__, argument="name" ) if not config_id: raise RequiredArgument( function=cls.create_task.__name__, argument="config_id" ) if not target_id: raise RequiredArgument( function=cls.create_task.__name__, argument="target_id" ) if not scanner_id: raise RequiredArgument( function=cls.create_task.__name__, argument="scanner_id" ) # don't allow to create a container task with create_task if target_id == "0": raise InvalidArgument( function=cls.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": str(config_id)}) cmd.add_element("target", attrs={"id": str(target_id)}) cmd.add_element("scanner", attrs={"id": str(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): hosts_ordering = HostsOrdering(hosts_ordering) cmd.add_element("hosts_ordering", hosts_ordering.value) if alert_ids: for alert in alert_ids: cmd.add_element("alert", attrs={"id": str(alert)}) if schedule_id: cmd.add_element("schedule", attrs={"id": str(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: # 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: xml_prefs = cmd.add_element("preferences") for pref_name, pref_value in preferences.items(): xml_pref = xml_prefs.add_element("preference") xml_pref.add_element("scanner_name", pref_name) xml_pref.add_element("value", str(pref_value)) return cmd @classmethod def delete_task( cls, task_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing task Args: 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=cls.delete_task.__name__, argument="task_id" ) cmd = XmlCommand("delete_task") cmd.set_attribute("task_id", str(task_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_tasks( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, trash: Optional[bool] = None, details: Optional[bool] = None, schedules_only: Optional[bool] = None, ignore_pagination: Optional[bool] = None, ) -> Request: """Request a list of tasks Args: 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 ignore_pagination: Whether to ignore pagination settings (filter terms "first" and "rows"). Default is False. """ cmd = XmlCommand("get_tasks") cmd.set_attribute("usage_type", "scan") cmd.add_filter(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)) if ignore_pagination is not None: cmd.set_attribute("ignore_pagination", to_bool(ignore_pagination)) return cmd @classmethod def get_task(cls, task_id: EntityID) -> Request: """Request a single task Args: task_id: UUID of an existing task """ if not task_id: raise RequiredArgument( function=cls.get_task.__name__, argument="task_id" ) cmd = XmlCommand("get_tasks") cmd.set_attribute("task_id", str(task_id)) cmd.set_attribute("usage_type", "scan") # for single entity always request all details cmd.set_attribute("details", "1") return cmd @classmethod def modify_task( cls, task_id: EntityID, *, name: Optional[str] = None, config_id: Optional[EntityID] = None, target_id: Optional[EntityID] = None, scanner_id: Optional[EntityID] = None, alterable: Optional[bool] = None, hosts_ordering: Optional[HostsOrdering] = None, schedule_id: Optional[EntityID] = None, schedule_periods: Optional[int] = None, comment: Optional[str] = None, alert_ids: Optional[Sequence[EntityID]] = None, observers: Optional[Sequence[str]] = None, preferences: Optional[Mapping[str, SupportsStr]] = None, ) -> Request: """Modifies an existing task. Args: 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. """ if not task_id: raise RequiredArgument( function=cls.modify_task.__name__, argument="task_id" ) cmd = XmlCommand("modify_task") cmd.set_attribute("task_id", str(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": str(config_id)}) if target_id: cmd.add_element("target", attrs={"id": str(target_id)}) if alterable is not None: cmd.add_element("alterable", to_bool(alterable)) if hosts_ordering: if not isinstance(hosts_ordering, HostsOrdering): hosts_ordering = HostsOrdering(hosts_ordering) cmd.add_element("hosts_ordering", hosts_ordering.value) if scanner_id: cmd.add_element("scanner", attrs={"id": str(scanner_id)}) if schedule_id: cmd.add_element("schedule", attrs={"id": str(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 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: cmd.add_element("observers", to_comma_list(observers)) if preferences is not None: xml_prefs = cmd.add_element("preferences") for pref_name, pref_value in preferences.items(): xml_pref = xml_prefs.add_element("preference") xml_pref.add_element("scanner_name", pref_name) xml_pref.add_element("value", str(pref_value)) return cmd @classmethod def move_task( cls, task_id: EntityID, *, slave_id: Optional[EntityID] = None ) -> Request: """Move an existing task to another GMP slave scanner or the master Args: task_id: UUID of the task to be moved slave_id: UUID of the sensor to reassign the task to, empty for master. """ if not task_id: raise RequiredArgument( function=cls.move_task.__name__, argument="task_id" ) cmd = XmlCommand("move_task") cmd.set_attribute("task_id", str(task_id)) if slave_id is not None: cmd.set_attribute("slave_id", str(slave_id)) return cmd @classmethod def start_task(cls, task_id: EntityID) -> Request: """Start an existing task Args: task_id: UUID of the task to be started """ if not task_id: raise RequiredArgument( function=cls.start_task.__name__, argument="task_id" ) cmd = XmlCommand("start_task") cmd.set_attribute("task_id", str(task_id)) return cmd @classmethod def resume_task(cls, task_id: EntityID) -> Request: """Resume an existing stopped task Args: task_id: UUID of the task to be resumed """ if not task_id: raise RequiredArgument( function=cls.resume_task.__name__, argument="task_id" ) cmd = XmlCommand("resume_task") cmd.set_attribute("task_id", str(task_id)) return cmd @classmethod def stop_task(cls, task_id: EntityID) -> Request: """Stop an existing running task Args: task_id: UUID of the task to be stopped """ if not task_id: raise RequiredArgument( function=cls.stop_task.__name__, argument="task_id" ) cmd = XmlCommand("stop_task") cmd.set_attribute("task_id", str(task_id)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_tickets.py000066400000000000000000000133231466406635600240660ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class TicketStatus(Enum): """Enum for ticket status""" OPEN = "Open" FIXED = "Fixed" CLOSED = "Closed" class Tickets: @classmethod def clone_ticket(cls, ticket_id: EntityID) -> Request: """Clone an existing ticket Args: ticket_id: UUID of an existing ticket to clone from """ if not ticket_id: raise RequiredArgument( function=cls.clone_ticket.__name__, argument="ticket_id" ) cmd = XmlCommand("create_ticket") cmd.add_element("copy", str(ticket_id)) return cmd @classmethod def create_ticket( cls, *, result_id: EntityID, assigned_to_user_id: EntityID, note: str, comment: Optional[str] = None, ) -> Request: """Create a new ticket Args: 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 """ if not result_id: raise RequiredArgument( function=cls.create_ticket.__name__, argument="result_id" ) if not assigned_to_user_id: raise RequiredArgument( function=cls.create_ticket.__name__, argument="assigned_to_user_id", ) if not note: raise RequiredArgument( function=cls.create_ticket.__name__, argument="note" ) cmd = XmlCommand("create_ticket") result = cmd.add_element("result") result.set_attribute("id", str(result_id)) assigned = cmd.add_element("assigned_to") user = assigned.add_element("user") user.set_attribute("id", str(assigned_to_user_id)) cmd.add_element("open_note", note) if comment: cmd.add_element("comment", comment) return cmd @classmethod def delete_ticket( cls, ticket_id: EntityID, *, ultimate: Optional[bool] = False ) -> Request: """Deletes an existing ticket Args: 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=cls.delete_ticket.__name__, argument="ticket_id" ) cmd = XmlCommand("delete_ticket") cmd.set_attribute("ticket_id", str(ticket_id)) cmd.set_attribute("ultimate", to_bool(ultimate)) return cmd @staticmethod def get_tickets( *, trash: Optional[bool] = None, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, ) -> Request: """Request a list of tickets Args: 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 """ cmd = XmlCommand("get_tickets") cmd.add_filter(filter_string, filter_id) if trash is not None: cmd.set_attribute("trash", to_bool(trash)) return cmd @classmethod def get_ticket(cls, ticket_id: EntityID) -> Request: """Request a single ticket Args: ticket_id: UUID of an existing ticket """ if not ticket_id: raise RequiredArgument( function=cls.get_ticket.__name__, argument="ticket_id" ) cmd = XmlCommand("get_tickets") cmd.set_attribute("ticket_id", str(ticket_id)) return cmd @classmethod def modify_ticket( cls, ticket_id: EntityID, *, status: Optional[Union[TicketStatus, str]] = None, note: Optional[str] = None, assigned_to_user_id: Optional[EntityID] = None, comment: Optional[str] = None, ) -> Request: """Modify a single ticket Args: 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 """ if not ticket_id: raise RequiredArgument( function=cls.modify_ticket.__name__, argument="ticket_id" ) if status and not note: raise RequiredArgument( function=cls.modify_ticket.__name__, argument="note" ) if note and not status: raise RequiredArgument( function=cls.modify_ticket.__name__, argument="status" ) cmd = XmlCommand("modify_ticket") cmd.set_attribute("ticket_id", str(ticket_id)) if assigned_to_user_id: assigned = cmd.add_element("assigned_to") user = assigned.add_element("user") user.set_attribute("id", str(assigned_to_user_id)) if status: if not isinstance(status, TicketStatus): status = TicketStatus(status) cmd.add_element("status", status.value) cmd.add_element(f"{status.name.lower()}_note", note) if comment: cmd.add_element("comment", comment) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_tls_certificates.py000066400000000000000000000130451466406635600257500ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool from gvm.xml import XmlCommand from .._entity_id import EntityID class TLSCertificates: @classmethod def clone_tls_certificate(cls, tls_certificate_id: EntityID) -> Request: """Modifies an existing TLS certificate. Args: tls_certificate_id: The UUID of an existing TLS certificate """ if not tls_certificate_id: raise RequiredArgument( function=cls.clone_tls_certificate.__name__, argument="tls_certificate_id", ) cmd = XmlCommand("create_tls_certificate") cmd.add_element("copy", str(tls_certificate_id)) return cmd @classmethod def create_tls_certificate( cls, name: str, certificate: str, *, comment: Optional[str] = None, trust: Optional[bool] = None, ) -> Request: """Create a new TLS certificate Args: 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. """ if not name: raise RequiredArgument( function=cls.create_tls_certificate.__name__, argument="name" ) if not certificate: raise RequiredArgument( function=cls.create_tls_certificate.__name__, argument="certificate", ) cmd = XmlCommand("create_tls_certificate") cmd.add_element("name", name) cmd.add_element("certificate", certificate) if comment: cmd.add_element("comment", comment) if trust is not None: cmd.add_element("trust", to_bool(trust)) return cmd @classmethod def delete_tls_certificate(cls, tls_certificate_id: EntityID) -> Request: """Deletes an existing tls certificate Args: tls_certificate_id: UUID of the tls certificate to be deleted. """ if not tls_certificate_id: raise RequiredArgument( function=cls.delete_tls_certificate.__name__, argument="tls_certificate_id", ) cmd = XmlCommand("delete_tls_certificate") cmd.set_attribute("tls_certificate_id", str(tls_certificate_id)) return cmd @staticmethod def get_tls_certificates( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, include_certificate_data: Optional[bool] = None, details: Optional[bool] = None, ) -> Request: """Request a list of TLS certificates Args: 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 """ cmd = XmlCommand("get_tls_certificates") cmd.add_filter(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 cmd @classmethod def get_tls_certificate(cls, tls_certificate_id: EntityID) -> Request: """Request a single TLS certificate Args: tls_certificate_id: UUID of an existing TLS certificate """ cmd = XmlCommand("get_tls_certificates") if not tls_certificate_id: raise RequiredArgument( function=cls.get_tls_certificate.__name__, argument="tls_certificate_id", ) cmd.set_attribute("tls_certificate_id", str(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 cmd @classmethod def modify_tls_certificate( cls, tls_certificate_id: EntityID, *, name: Optional[str] = None, comment: Optional[str] = None, trust: Optional[bool] = None, ) -> Request: """Modifies an existing TLS certificate. Args: 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. """ if not tls_certificate_id: raise RequiredArgument( function=cls.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 is not None: cmd.add_element("trust", to_bool(trust)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_trashcan.py000066400000000000000000000017651466406635600242320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.xml import XmlCommand from .._entity_id import EntityID class TrashCan: @staticmethod def empty_trashcan() -> Request: """Empty the trashcan Remove all entities from the trashcan. **Attention:** this command can not be reverted """ return XmlCommand("empty_trashcan") @classmethod def restore_from_trashcan(cls, entity_id: EntityID) -> Request: """Restore an entity from the trashcan Args: entity_id: ID of the entity to be restored from the trashcan """ if not entity_id: raise RequiredArgument( function=cls.restore_from_trashcan.__name__, argument="entity_id", ) cmd = XmlCommand("restore") cmd.set_attribute("id", str(entity_id)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_user_settings.py000066400000000000000000000043731466406635600253230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_base64 from gvm.xml import XmlCommand from .._entity_id import EntityID class UserSettings: @staticmethod def get_user_settings(*, filter_string: Optional[str] = None) -> Request: """Request a list of user settings Args: filter_string: Filter term to use for the query """ cmd = XmlCommand("get_settings") if filter_string: cmd.set_attribute("filter", filter_string) return cmd @classmethod def get_user_setting(cls, setting_id: EntityID) -> Request: """Request a single user setting Args: setting_id: UUID of an existing setting """ cmd = XmlCommand("get_settings") if not setting_id: raise RequiredArgument( function=cls.get_user_setting.__name__, argument="setting_id" ) cmd.set_attribute("setting_id", str(setting_id)) return cmd @classmethod def modify_user_setting( cls, *, setting_id: Optional[EntityID] = None, name: Optional[str] = None, value: Optional[str] = None, ) -> Request: """Modifies an existing user setting. Args: 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. """ if not setting_id and not name: raise RequiredArgument( function=cls.modify_user_setting.__name__, argument="setting_id or name argument", ) if value is None: raise RequiredArgument( function=cls.modify_user_setting.__name__, argument="value argument", ) cmd = XmlCommand("modify_setting") if setting_id: cmd.set_attribute("setting_id", str(setting_id)) else: cmd.add_element("name", name) cmd.add_element("value", to_base64(value)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_users.py000066400000000000000000000157231466406635600235670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.utils import to_bool, to_comma_list from gvm.xml import XmlCommand from .._entity_id import EntityID class UserAuthType(Enum): """Enum for Sources allowed for authentication for the user""" FILE = "file" LDAP_CONNECT = "ldap_connect" RADIUS_CONNECT = "radius_connect" class Users: @classmethod def create_user( cls, name: str, *, password: Optional[str] = None, hosts: Optional[list[str]] = None, hosts_allow: Optional[bool] = False, role_ids: Optional[list[EntityID]] = None, ) -> Request: """Create a new user Args: 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. role_ids: A list of role UUIDs for the user """ if not name: raise RequiredArgument( function=cls.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 role_ids: for role in role_ids: cmd.add_element("role", attrs={"id": str(role)}) return cmd @classmethod def modify_user( cls, user_id: EntityID, *, name: Optional[str] = None, comment: Optional[str] = None, password: Optional[str] = None, auth_source: Optional[Union[UserAuthType, str]] = None, role_ids: Optional[list[EntityID]] = None, hosts: Optional[list[str]] = None, hosts_allow: Optional[bool] = False, group_ids: Optional[list[EntityID]] = None, ) -> Request: """Modify 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. Args: 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. group_ids: List of group UUIDs for the user. """ if not user_id: raise RequiredArgument( function=cls.modify_user.__name__, argument="user_id" ) cmd = XmlCommand("modify_user") cmd.set_attribute("user_id", str(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 comment: cmd.add_element("comment", comment) if password: cmd.add_element("password", password) if auth_source: xml_auth_src = cmd.add_element("sources") if not isinstance(auth_source, UserAuthType): auth_source = UserAuthType(auth_source) xml_auth_src.add_element("source", auth_source.value) if group_ids: xml_groups = cmd.add_element("groups") for group_id in group_ids: xml_groups.add_element("group", attrs={"id": group_id}) return cmd @classmethod def clone_user(cls, user_id: EntityID) -> Request: """Clone an existing user. Args: user_id: UUID of the user to be cloned. """ if not user_id: raise RequiredArgument( function=cls.clone_user.__name__, argument="user_id" ) cmd = XmlCommand("create_user") cmd.add_element("copy", str(user_id)) return cmd @classmethod def delete_user( cls, user_id: Optional[EntityID] = None, *, name: Optional[str] = None, inheritor_id: Optional[EntityID] = None, inheritor_name: Optional[str] = None, ) -> Request: """Delete an existing user Either user_id or name must be passed. Args: user_id: UUID of the task to be deleted. name: The name of the user to be deleted. inheritor_id: The UUID 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=cls.delete_user.__name__, argument="user_id or name" ) cmd = XmlCommand("delete_user") if user_id: cmd.set_attribute("user_id", str(user_id)) if name: cmd.set_attribute("name", name) if inheritor_id: cmd.set_attribute("inheritor_id", str(inheritor_id)) if inheritor_name: cmd.set_attribute("inheritor_name", inheritor_name) return cmd @staticmethod def get_users( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, ) -> Request: """Request a list of users Args: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query """ cmd = XmlCommand("get_users") cmd.add_filter(filter_string, filter_id) return cmd @classmethod def get_user(cls, user_id: EntityID) -> Request: """Request a single user Args: user_id: UUID of the user to be requested. """ if not user_id: raise RequiredArgument( function=cls.get_user.__name__, argument="user_id" ) cmd = XmlCommand("get_users") cmd.set_attribute("user_id", str(user_id)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v224/_vulnerabilities.py000066400000000000000000000024111466406635600256150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.xml import XmlCommand from .._entity_id import EntityID class Vulnerabilities: @staticmethod def get_vulnerabilities( *, filter_string: Optional[str] = None, filter_id: Optional[EntityID] = None, ) -> Request: """Request a list of vulnerabilities Args: filter_string: Filter term to use for the query filter_id: UUID of an existing filter to use for the query """ cmd = XmlCommand("get_vulns") cmd.add_filter(filter_string, filter_id) return cmd @classmethod def get_vulnerability(cls, vulnerability_id: EntityID) -> Request: """Request a single vulnerability Args: vulnerability_id: ID of an existing vulnerability """ if not vulnerability_id: raise RequiredArgument( function=cls.get_vulnerability.__name__, argument="vulnerability_id", ) cmd = XmlCommand("get_vulns") cmd.set_attribute("vuln_id", str(vulnerability_id)) return cmd python-gvm-24.8.0/gvm/protocols/gmp/requests/v225/000077500000000000000000000000001466406635600217065ustar00rootroot00000000000000python-gvm-24.8.0/gvm/protocols/gmp/requests/v225/__init__.py000066400000000000000000000047141466406635600240250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """ GMP Request implementations for GMP version 22.5. """ from .._entity_id import EntityID from .._version import Version from ..v224 import ( Aggregates, AggregateStatistic, AlertCondition, AlertEvent, AlertMethod, Alerts, AliveTest, Audits, Authentication, CertBundAdvisories, Cpes, CredentialFormat, Credentials, CredentialType, Cves, DfnCertAdvisories, EntityType, Feed, FeedType, Filters, FilterType, Groups, Help, HelpFormat, Hosts, HostsOrdering, InfoType, Notes, Nvts, OperatingSystems, Overrides, Permissions, PermissionSubjectType, Policies, PortLists, PortRangeType, ReportFormats, ReportFormatType, Reports, Results, Roles, ScanConfigs, Scanners, ScannerType, Schedules, SecInfo, Severity, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, SortOrder, SystemReports, Tags, Targets, Tasks, Tickets, TicketStatus, TLSCertificates, TrashCan, UserAuthType, Users, UserSettings, Vulnerabilities, ) from ._resource_names import ResourceNames, ResourceType __all__ = ( "Aggregates", "AggregateStatistic", "Alerts", "AlertCondition", "AlertEvent", "AlertMethod", "AliveTest", "Audits", "Authentication", "CertBundAdvisories", "Cpes", "Credentials", "CredentialFormat", "CredentialType", "Cves", "DfnCertAdvisories", "EntityID", "EntityType", "Feed", "FeedType", "Filters", "FilterType", "Groups", "Help", "HelpFormat", "Hosts", "HostsOrdering", "InfoType", "Notes", "Nvts", "OperatingSystems", "Overrides", "Permissions", "PermissionSubjectType", "Policies", "PortLists", "PortRangeType", "ReportFormatType", "ReportFormats", "Reports", "ResourceNames", "ResourceType", "Results", "Roles", "ScanConfigs", "Scanners", "ScannerType", "Schedules", "SecInfo", "Severity", "SortOrder", "SnmpAuthAlgorithm", "SnmpPrivacyAlgorithm", "SystemReports", "Tags", "Targets", "Tasks", "Tickets", "TicketStatus", "TLSCertificates", "TrashCan", "UserAuthType", "UserSettings", "Users", "Version", "Vulnerabilities", ) python-gvm-24.8.0/gvm/protocols/gmp/requests/v225/_resource_names.py000066400000000000000000000065061466406635600254400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later from typing import Optional, Union from gvm._enum import Enum from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.xml import XmlCommand from .._entity_id import EntityID class ResourceType(Enum): """Enum for resource types""" ALERT = "ALERT" CERT_BUND_ADV = "CERT_BUND_ADV" CONFIG = "CONFIG" CPE = "CPE" CREDENTIAL = "CREDENTIAL" CVE = "CVE" DFN_CERT_ADV = "DFN_CERT_ADV" FILTER = "FILTER" GROUP = "GROUP" HOST = "HOST" NOTE = "NOTE" NVT = "NVT" OS = "OS" OVERRIDE = "OVERRIDE" PERMISSION = "PERMISSION" PORT_LIST = "PORT_LIST" REPORT_FORMAT = "REPORT_FORMAT" REPORT = "REPORT" RESULT = "RESULT" ROLE = "ROLE" SCANNER = "SCANNER" SCHEDULE = "SCHEDULE" TARGET = "TARGET" TASK = "TASK" TLS_CERTIFICATE = "TLS_CERTIFICATE" USER = "USER" class ResourceNames: @classmethod def get_resource_names( cls, resource_type: Union[ResourceType, str], *, filter_string: Optional[str] = None, ) -> Request: """Request a list of resource names and IDs Args: resource_type: Type must be either ALERT, CERT_BUND_ADV, CONFIG, CPE, CREDENTIAL, CVE, DFN_CERT_ADV, FILTER, GROUP, HOST, NOTE, NVT, OS, OVERRIDE, PERMISSION, PORT_LIST, REPORT_FORMAT, REPORT, RESULT, ROLE, SCANNER, SCHEDULE, TARGET, TASK, TLS_CERTIFICATE or USER filter_string: Filter term to use for the query """ cmd = XmlCommand("get_resource_names") if not resource_type: raise RequiredArgument( function=cls.get_resource_names.__name__, argument="resource_type", ) if not isinstance(resource_type, ResourceType): resource_type = ResourceType(resource_type) cmd.set_attribute("type", resource_type.value) cmd.add_filter(filter_string, None) return cmd @classmethod def get_resource_name( cls, resource_id: EntityID, resource_type: Union[ResourceType, str], ) -> Request: """Request a single resource name Args: resource_id: ID of an existing resource resource_type: Type must be either ALERT, CERT_BUND_ADV, CONFIG, CPE, CREDENTIAL, CVE, DFN_CERT_ADV, FILTER, GROUP, HOST, NOTE, NVT, OS, OVERRIDE, PERMISSION, PORT_LIST, REPORT_FORMAT, REPORT, RESULT, ROLE, SCANNER, SCHEDULE, TARGET, TASK, TLS_CERTIFICATE or USER """ if not resource_type: raise RequiredArgument( function=cls.get_resource_name.__name__, argument="resource_type", ) if not isinstance(resource_type, ResourceType): resource_type = ResourceType(resource_type) if not resource_id: raise RequiredArgument( function=cls.get_resource_name.__name__, argument="resource_id" ) cmd = XmlCommand("get_resource_names") cmd.set_attribute("resource_id", str(resource_id)) cmd.set_attribute("type", resource_type.value) return cmd python-gvm-24.8.0/gvm/protocols/latest.py000066400000000000000000000014331466406635600204210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """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.gmp.GMPv224` - :py:class:`gvm.protocols.ospv1.Osp` .. _Greenbone Management Protocol: https://docs.greenbone.net/API/GMP/gmp.html """ from .gmp import ( GMPv225 as Gmp, ) from .ospv1 import Osp __all__ = [ "Gmp", "Osp", ] python-gvm-24.8.0/gvm/protocols/next.py000066400000000000000000000014331466406635600201030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """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.gmp.GMPv225` - :py:class:`gvm.protocols.ospv1.Osp` .. _Greenbone Management Protocol: https://docs.greenbone.net/API/GMP/gmp.html """ from .gmp import ( GMPv225 as Gmp, ) from .ospv1 import Osp __all__ = [ "Gmp", "Osp", ] python-gvm-24.8.0/gvm/protocols/ospv1.py000066400000000000000000000213221466406635600201740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """ 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 typing import Any, Optional from gvm.errors import InvalidArgument, RequiredArgument from gvm.utils import to_bool from gvm.xml import XmlCommand, XmlCommandElement from ._protocol import GvmProtocol, T from .core import Request, Response logger = logging.getLogger(__name__) PROTOCOL_VERSION = (1, 2) def create_credentials_element( xml_credentials: XmlCommandElement, credentials: dict[str, dict[str, str]] ): """Generates an xml element with credentials.""" for service, credential in credentials.items(): cred_type = credential.get("type", "") server_port = credential.get("port", "") username = credential.get("username") password = credential.get("password") xml_credential = xml_credentials.add_element("credential") xml_credential.set_attribute("type", cred_type) xml_credential.set_attribute("port", server_port) xml_credential.set_attribute("service", service) xml_credential.add_element("username", username) xml_credential.add_element("password", password) return xml_credentials def create_vt_selection_element( xml_vt_selection: XmlCommandElement, vt_selection: dict[str, Any] ): """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): xml_vt = xml_vt_selection.add_element( "vt_single", attrs={"id": vt_id} ) if vt_values: for key, value in vt_values.items(): xml_vt.add_element("vt_value", value, attrs={"id": key}) elif vt_id == "vt_groups" and isinstance(vt_values, list): for group in vt_values: xml_vt_selection.add_element( "vt_group", attrs={"filter": group} ) else: raise InvalidArgument( f"It was not possible to add {vt_id} to the VTs selection." ) return xml_vt_selection class Osp(GvmProtocol[T]): @staticmethod def get_protocol_version() -> tuple[int, int]: """Determine the Open Scanner Protocol version. Returns: tuple: Implemented version of the Open Scanner Protocol """ return PROTOCOL_VERSION def _send_command(self, cmd: Request) -> Response: try: return super()._send_command(cmd) finally: # OSP is stateless. Therefore the connection is closed after each # response and we must reset the connection self.disconnect() def get_version(self) -> T: """Get the version of the OSPD server which is connected to.""" cmd = XmlCommand("get_version") return self._send_and_transform_command(cmd) def help(self) -> T: """Get the help text.""" cmd = XmlCommand("help") return self._send_and_transform_command(cmd) def get_scans( self, scan_id: Optional[str] = None, details: bool = True, pop_results: bool = False, ) -> T: """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 """ cmd = XmlCommand("get_scans") if scan_id: cmd.set_attribute("scan_id", scan_id) cmd.set_attribute("details", to_bool(details)) cmd.set_attribute("pop_results", to_bool(pop_results)) return self._send_and_transform_command(cmd) def delete_scan(self, scan_id: str) -> T: """Delete a finished scan. Arguments: scan_id: UUID identifier for a finished scan. """ 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_and_transform_command(cmd) def get_scanner_details(self) -> T: """Return scanner description and parameters.""" cmd = XmlCommand("get_scanner_details") return self._send_and_transform_command(cmd) def get_vts(self, vt_id: Optional[str] = None) -> T: """Return information about vulnerability tests, if offered by scanner. Args: vt_id: UUID identifier for a vulnerability test. """ cmd = XmlCommand("get_vts") if vt_id: cmd.set_attribute("vt_id", vt_id) return self._send_and_transform_command(cmd) def start_scan( self, scan_id: Optional[str] = None, parallel: int = 1, target=None, ports=None, targets: Optional[list[dict[str, str]]] = None, scanner_params: Optional[dict[str, Any]] = None, vt_selection: Optional[dict[str, Any]] = None, ) -> T: """Start a new scan. Args: scan_id: UUID identifier for a running scan. parallel: Number of parallel scanned targets. Default 1. target: Deprecated. Please use targets instead. targets: List of dictionaries. See example. ports: Deprecated. Ports to use for target parameter. scanner_params:: Dictionary of scanner parameters. vt_selection:: Vulnerability tests to select. See example. 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 xml_scan_params = cmd.add_element("scanner_params") if scanner_params: xml_scan_params.set_attributes(scanner_params) if targets: xml_targets = cmd.add_element("targets") for target in targets: xml_target = xml_targets.add_element("target") hosts = target.get("hosts") ports = target.get("ports") credentials = target.get("credentials") xml_target.add_element("hosts", hosts) xml_target.add_element("ports", ports) if credentials: create_credentials_element( xml_target.add_element("credentials"), 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: create_vt_selection_element( cmd.add_element("vt_selection"), vt_selection ) return self._send_and_transform_command(cmd) def stop_scan(self, scan_id: str) -> T: """Stop a currently running scan. Args: scan_id: UUID identifier for a running scan. """ 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_and_transform_command(cmd) python-gvm-24.8.0/gvm/py.typed000066400000000000000000000000001466406635600162130ustar00rootroot00000000000000python-gvm-24.8.0/gvm/transforms.py000066400000000000000000000035221466406635600173000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # """ Module for transforming responses """ from lxml import etree from gvm.protocols.core import Response from .errors import GvmError, GvmResponseError, GvmServerError from .xml import Element, 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: Response) -> Element: return etree.XML(bytes(response), parser=self._parser) def __call__(self, response: Response) -> Element: return self._convert_response(response) def check_command_status(root: Element): status = root.get("status") if status is None: raise GvmServerError("No status in response.", str(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: Response) -> Response: # type: ignore[override] 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: Response) -> Element: root = self._convert_response(response) check_command_status(root) return root python-gvm-24.8.0/gvm/utils.py000066400000000000000000000107561466406635600162510ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # # pylint: disable=arguments-differ, redefined-builtin import base64 import logging import re import warnings from functools import wraps from typing import ( Any, Callable, Iterable, List, Optional, Protocol, Type, Union, ) from gvm.xml import XmlCommand, XmlError, parse_xml logger = logging.getLogger(__name__) class TypesDict(dict): """For dot.notation access to dictionary attributes""" __getattr__ = dict.get __setattr__ = dict.__setitem__ # type: ignore[assignment] __delattr__ = dict.__delitem__ # type: ignore[assignment] def deprecation(message: str): warnings.warn(message, DeprecationWarning, stacklevel=2) def deprecated( _func_or_cls: Union[str, Callable, Type, None] = None, *, since: Optional[str] = None, reason: Optional[str] = None, ): """ A decorator to mark functions, classes and methods as deprecated Args: since: An optional version since the referenced item is deprecated. reason: An optional reason why the references item is deprecated. Examples: .. code-block:: python from gvm.utils import deprecated @deprecated def my_function(*args, **kwargs): ... @deprecated("The function is obsolete. Please use my_func instead.") def my_function(*args, **kwargs): ... @deprecated( since="1.2.3", reason="The function is obsolete. Please use my_func instead." ) def my_function(*args, **kwargs): ... @deprecated(reason="The class will be removed in version 3.4.5") class Foo: ... class Foo: @deprecated(since="2.3.4") def bar(self, *args, **kwargs): ... """ if isinstance(_func_or_cls, str): reason = _func_or_cls _func_or_cls = None def decorator_repeat(func_or_cls): module = func_or_cls.__module__ name = func_or_cls.__name__ if module == "__main__": msg = f"{name} is deprecated." else: msg = f"{module}.{name} is deprecated." if since: msg += f" It is deprecated since version {since}." if reason: msg += f" {reason}" @wraps(func_or_cls) def wrapper(*args, **kwargs): warnings.warn(msg, category=DeprecationWarning, stacklevel=3) return func_or_cls(*args, **kwargs) return wrapper if _func_or_cls is None: return decorator_repeat else: return decorator_repeat(_func_or_cls) 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 = parse_xml(xml) status = root.attrib["status"] return status is not None and status[0] == "2" except KeyError: logger.error("Not received an status code within the response.") return False except XmlError as e: logger.error("Error while parsing the command status: %s", e) return False def to_dotted_types_dict(types: List) -> TypesDict: """Create a dictionary accessible via dot notation""" dic = {} for typ in types: dic[typ.__name__] = typ return TypesDict(dic) def to_bool(value: Union[bool, int, None]) -> str: return "1" if value else "0" def to_base64(value: str) -> str: return base64.b64encode(value.encode("utf-8")).decode(encoding="utf-8") class SupportsStr(Protocol): def __str__(self) -> str: ... def to_comma_list(value: Iterable[SupportsStr]) -> str: return ",".join([str(value) for value in value]) @deprecated(since="24.3.0", reason="Please use XmlCommand.add_filter instead.") def add_filter( cmd: XmlCommand, filter_string: Optional[str], filter_id: Optional[str] ) -> None: cmd.add_filter(filter_string, filter_id) def is_list_like(value: Any) -> bool: return isinstance(value, (list, tuple)) def check_port(value: str) -> bool: pattern = re.compile( r"^(cpe:[^\s]+|(general|[1-9][0-9]{0,4})/[0-9A-Za-z]+)$" ) return bool(pattern.fullmatch(value)) python-gvm-24.8.0/gvm/xml.py000066400000000000000000000131221466406635600156770ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import sys from io import IOBase from typing import AnyStr, Optional, TextIO, Union from uuid import UUID from lxml.etree import DocInfo, SubElement, XMLParser from lxml.etree import Element as create_element from lxml.etree import Error as EtreeError from lxml.etree import _Element as Element from lxml.etree import iselement as is_xml_element from lxml.etree import tostring as xml_to_string from gvm.errors import GvmError, InvalidArgumentType __all__ = ( "Element", "create_parser", "parse_xml", "XmlCommandElement", "XmlCommand", "pretty_print", ) class XmlError(GvmError): pass def check_xml_document( root_element: Element, forbid_dtd: bool = False, forbid_entities: bool = True, ) -> None: """ Check an element for DTD and entity declarations """ doc_info: DocInfo = root_element.getroottree().docinfo if doc_info.doctype: # type: ignore if forbid_dtd: raise XmlError( "XML document contains a forbidden DTD declaration " f"{doc_info.system_url} {doc_info.public_id}" # type: ignore ) if forbid_entities: for dtd in doc_info.internalDTD, doc_info.externalDTD: if dtd is None: continue for entity in dtd.iterentities(): # type: ignore raise XmlError( f"XML Document contains forbidden entity declaration " f"{entity.name} {entity.content}" ) def create_parser(): # huge_tree => disable security restrictions and support very deep trees and # very long text content (for get_reports) # resolve_entities=False => disable entity resolution for security reasons return XMLParser(encoding="utf-8", huge_tree=True, resolve_entities=False) def parse_xml(xml: AnyStr) -> Element: """ Parse an XML string and return the root element Raises an XmlError if the XML is invalid. """ parser = create_parser() try: parser.feed(xml) element = parser.close() check_xml_document(element) return element except EtreeError as e: raise XmlError(f"Invalid XML {xml!r}. Error was {e}") from e class XmlCommandElement: def __init__(self, element: Element): self._element = element def add_element( self, name: str, text: Optional[str] = None, *, attrs: Optional[dict] = None, ) -> "XmlCommandElement": node = SubElement(self._element, name, attrib=attrs) node.text = text return XmlCommandElement(node) def set_attribute(self, name: str, value: str) -> "XmlCommandElement": self._element.set(name, value) return self def set_attributes(self, attrs: dict[str, str]) -> "XmlCommandElement": """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) return self def append_xml_str(self, xml_text: str) -> None: """Append a xml element in string format.""" node = parse_xml(xml_text) self._element.append(node) def to_string(self) -> str: return self.to_bytes().decode("utf-8") def to_bytes(self) -> bytes: return xml_to_string(self._element) def __str__(self) -> str: return self.to_string() def __bytes__(self) -> bytes: return self.to_bytes() class XmlCommand(XmlCommandElement): def __init__(self, name: str) -> None: super().__init__(create_element(name)) def add_filter( self, filter_string: Optional[str], filter_id: Optional[Union[str, UUID]], ) -> "XmlCommand": if filter_string: self.set_attribute("filter", filter_string) if filter_id: self.set_attribute("filt_id", str(filter_id)) return self def pretty_print( xml: Union[str, list[Union[Element, str]], Element], file: Union[TextIO, 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, TextIO)): raise TypeError( f"Type needs to be from IOBase or TextIO, not {type(file)}." ) from None if isinstance(xml, list): for item in xml: if is_xml_element(item): file.write( xml_to_string(item, pretty_print=True).decode( sys.getdefaultencoding() + "\n" ) ) else: file.write(str(item) + "\n") elif is_xml_element(xml): file.write( xml_to_string(xml, pretty_print=True).decode( sys.getdefaultencoding() + "\n" ) ) elif isinstance(xml, str): tree = parse_xml(xml) file.write( xml_to_string(tree, pretty_print=True).decode( sys.getdefaultencoding() + "\n" ) ) else: raise InvalidArgumentType( function=pretty_print.__name__, argument="xml", arg_type="" ) python-gvm-24.8.0/poetry.lock000066400000000000000000003623011466406635600161360ustar00rootroot00000000000000# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. [[package]] name = "alabaster" version = "0.7.16" description = "A light, configurable Sphinx theme" optional = false python-versions = ">=3.9" files = [ {file = "alabaster-0.7.16-py3-none-any.whl", hash = "sha256:b46733c07dce03ae4e150330b975c75737fa60f0a7c591b6c8bf4928a28e2c92"}, {file = "alabaster-0.7.16.tar.gz", hash = "sha256:75a8b99c28a5dad50dd7f8ccdd447a121ddb3892da9e53d1ca5cca3106d58d65"}, ] [[package]] name = "anyio" version = "4.4.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false python-versions = ">=3.8" files = [ {file = "anyio-4.4.0-py3-none-any.whl", hash = "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7"}, {file = "anyio-4.4.0.tar.gz", hash = "sha256:5aadc6a1bbb7cdb0bede386cac5e2940f5e2ff3aa20277e991cf028e0585ce94"}, ] [package.dependencies] exceptiongroup = {version = ">=1.0.2", markers = "python_version < \"3.11\""} idna = ">=2.8" sniffio = ">=1.1" typing-extensions = {version = ">=4.1", markers = "python_version < \"3.11\""} [package.extras] doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"] trio = ["trio (>=0.23)"] [[package]] name = "autohooks" version = "24.2.0" description = "Library for managing git hooks" optional = false python-versions = ">=3.9,<4.0" files = [ {file = "autohooks-24.2.0-py3-none-any.whl", hash = "sha256:a2097de2e092fa7b78a17b63b73980d3cc42b01065feb2caf0d41e2bb506621b"}, {file = "autohooks-24.2.0.tar.gz", hash = "sha256:ee929a9f7ff68e61c73201de817b679df168b4465be1026550a71956b419200b"}, ] [package.dependencies] pontos = ">=22.8.0" rich = ">=12.5.1" shtab = ">=1.7.0" tomlkit = ">=0.5.11" [[package]] name = "autohooks-plugin-black" version = "23.10.0" description = "An autohooks plugin for python code formatting via black" optional = false python-versions = ">=3.9,<4.0" files = [ {file = "autohooks_plugin_black-23.10.0-py3-none-any.whl", hash = "sha256:88d648251df749586af9ea5be3105daa4358ed916b61aee738d0727387214470"}, {file = "autohooks_plugin_black-23.10.0.tar.gz", hash = "sha256:8415b5f566d861236bde2b0973699f64a8b861208af4fa05fe04a1f923ea3ef6"}, ] [package.dependencies] autohooks = ">=21.6.0" black = ">=20.8" [[package]] name = "autohooks-plugin-mypy" version = "23.10.0" description = "An autohooks plugin for python code static typing check with mypy" optional = false python-versions = ">=3.9,<4.0" files = [ {file = "autohooks_plugin_mypy-23.10.0-py3-none-any.whl", hash = "sha256:8ac36b74900b2f2456fec046126e564374acd6de2752d87255c6f71c4e6a73ff"}, {file = "autohooks_plugin_mypy-23.10.0.tar.gz", hash = "sha256:ebefaa83074b662de38c914f6cac9f4f8e3452e36f54a5834df3f1590cc0c540"}, ] [package.dependencies] autohooks = ">=21.7.0" mypy = ">=0.910" [[package]] name = "autohooks-plugin-ruff" version = "24.1.0" description = "An autohooks plugin for python code formatting via ruff" optional = false python-versions = ">=3.9,<4.0" files = [ {file = "autohooks_plugin_ruff-24.1.0-py3-none-any.whl", hash = "sha256:2a072805b60abb63311abab84a6600cde9112840ab68f39af53f517648341651"}, {file = "autohooks_plugin_ruff-24.1.0.tar.gz", hash = "sha256:1a8dd732a2e7215c1c66faa79ac499195859c499af7ce52284ee6003ece4f25c"}, ] [package.dependencies] autohooks = ">=23.4.0" ruff = ">=0.0.272" [[package]] name = "babel" version = "2.16.0" description = "Internationalization utilities" optional = false python-versions = ">=3.8" files = [ {file = "babel-2.16.0-py3-none-any.whl", hash = "sha256:368b5b98b37c06b7daf6696391c3240c938b37767d4584413e8438c5c435fa8b"}, {file = "babel-2.16.0.tar.gz", hash = "sha256:d1f3554ca26605fe173f3de0c65f750f5a42f924499bf134de6423582298e316"}, ] [package.extras] dev = ["freezegun (>=1.0,<2.0)", "pytest (>=6.0)", "pytest-cov"] [[package]] name = "bcrypt" version = "4.2.0" description = "Modern password hashing for your software and your servers" optional = false python-versions = ">=3.7" files = [ {file = "bcrypt-4.2.0-cp37-abi3-macosx_10_12_universal2.whl", hash = "sha256:096a15d26ed6ce37a14c1ac1e48119660f21b24cba457f160a4b830f3fe6b5cb"}, {file = "bcrypt-4.2.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c02d944ca89d9b1922ceb8a46460dd17df1ba37ab66feac4870f6862a1533c00"}, {file = "bcrypt-4.2.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1d84cf6d877918620b687b8fd1bf7781d11e8a0998f576c7aa939776b512b98d"}, {file = "bcrypt-4.2.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:1bb429fedbe0249465cdd85a58e8376f31bb315e484f16e68ca4c786dcc04291"}, {file = "bcrypt-4.2.0-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:655ea221910bcac76ea08aaa76df427ef8625f92e55a8ee44fbf7753dbabb328"}, {file = "bcrypt-4.2.0-cp37-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:1ee38e858bf5d0287c39b7a1fc59eec64bbf880c7d504d3a06a96c16e14058e7"}, {file = "bcrypt-4.2.0-cp37-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:0da52759f7f30e83f1e30a888d9163a81353ef224d82dc58eb5bb52efcabc399"}, {file = "bcrypt-4.2.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:3698393a1b1f1fd5714524193849d0c6d524d33523acca37cd28f02899285060"}, {file = "bcrypt-4.2.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:762a2c5fb35f89606a9fde5e51392dad0cd1ab7ae64149a8b935fe8d79dd5ed7"}, {file = "bcrypt-4.2.0-cp37-abi3-win32.whl", hash = "sha256:5a1e8aa9b28ae28020a3ac4b053117fb51c57a010b9f969603ed885f23841458"}, {file = "bcrypt-4.2.0-cp37-abi3-win_amd64.whl", hash = "sha256:8f6ede91359e5df88d1f5c1ef47428a4420136f3ce97763e31b86dd8280fbdf5"}, {file = "bcrypt-4.2.0-cp39-abi3-macosx_10_12_universal2.whl", hash = "sha256:c52aac18ea1f4a4f65963ea4f9530c306b56ccd0c6f8c8da0c06976e34a6e841"}, {file = "bcrypt-4.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3bbbfb2734f0e4f37c5136130405332640a1e46e6b23e000eeff2ba8d005da68"}, {file = "bcrypt-4.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3413bd60460f76097ee2e0a493ccebe4a7601918219c02f503984f0a7ee0aebe"}, {file = "bcrypt-4.2.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:8d7bb9c42801035e61c109c345a28ed7e84426ae4865511eb82e913df18f58c2"}, {file = "bcrypt-4.2.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:3d3a6d28cb2305b43feac298774b997e372e56c7c7afd90a12b3dc49b189151c"}, {file = "bcrypt-4.2.0-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:9c1c4ad86351339c5f320ca372dfba6cb6beb25e8efc659bedd918d921956bae"}, {file = "bcrypt-4.2.0-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:27fe0f57bb5573104b5a6de5e4153c60814c711b29364c10a75a54bb6d7ff48d"}, {file = "bcrypt-4.2.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:8ac68872c82f1add6a20bd489870c71b00ebacd2e9134a8aa3f98a0052ab4b0e"}, {file = "bcrypt-4.2.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:cb2a8ec2bc07d3553ccebf0746bbf3d19426d1c6d1adbd4fa48925f66af7b9e8"}, {file = "bcrypt-4.2.0-cp39-abi3-win32.whl", hash = "sha256:77800b7147c9dc905db1cba26abe31e504d8247ac73580b4aa179f98e6608f34"}, {file = "bcrypt-4.2.0-cp39-abi3-win_amd64.whl", hash = "sha256:61ed14326ee023917ecd093ee6ef422a72f3aec6f07e21ea5f10622b735538a9"}, {file = "bcrypt-4.2.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:39e1d30c7233cfc54f5c3f2c825156fe044efdd3e0b9d309512cc514a263ec2a"}, {file = "bcrypt-4.2.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:f4f4acf526fcd1c34e7ce851147deedd4e26e6402369304220250598b26448db"}, {file = "bcrypt-4.2.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:1ff39b78a52cf03fdf902635e4c81e544714861ba3f0efc56558979dd4f09170"}, {file = "bcrypt-4.2.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:373db9abe198e8e2c70d12b479464e0d5092cc122b20ec504097b5f2297ed184"}, {file = "bcrypt-4.2.0.tar.gz", hash = "sha256:cf69eaf5185fd58f268f805b505ce31f9b9fc2d64b376642164e9244540c1221"}, ] [package.extras] tests = ["pytest (>=3.2.1,!=3.3.0)"] typecheck = ["mypy"] [[package]] name = "beautifulsoup4" version = "4.12.3" description = "Screen-scraping library" optional = false python-versions = ">=3.6.0" files = [ {file = "beautifulsoup4-4.12.3-py3-none-any.whl", hash = "sha256:b80878c9f40111313e55da8ba20bdba06d8fa3969fc68304167741bbf9e082ed"}, {file = "beautifulsoup4-4.12.3.tar.gz", hash = "sha256:74e3d1928edc070d21748185c46e3fb33490f22f52a3addee9aee0f4f7781051"}, ] [package.dependencies] soupsieve = ">1.2" [package.extras] cchardet = ["cchardet"] chardet = ["chardet"] charset-normalizer = ["charset-normalizer"] html5lib = ["html5lib"] lxml = ["lxml"] [[package]] name = "black" version = "24.8.0" description = "The uncompromising code formatter." optional = false python-versions = ">=3.8" files = [ {file = "black-24.8.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:09cdeb74d494ec023ded657f7092ba518e8cf78fa8386155e4a03fdcc44679e6"}, {file = "black-24.8.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:81c6742da39f33b08e791da38410f32e27d632260e599df7245cccee2064afeb"}, {file = "black-24.8.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:707a1ca89221bc8a1a64fb5e15ef39cd755633daa672a9db7498d1c19de66a42"}, {file = "black-24.8.0-cp310-cp310-win_amd64.whl", hash = "sha256:d6417535d99c37cee4091a2f24eb2b6d5ec42b144d50f1f2e436d9fe1916fe1a"}, {file = "black-24.8.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:fb6e2c0b86bbd43dee042e48059c9ad7830abd5c94b0bc518c0eeec57c3eddc1"}, {file = "black-24.8.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:837fd281f1908d0076844bc2b801ad2d369c78c45cf800cad7b61686051041af"}, {file = "black-24.8.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:62e8730977f0b77998029da7971fa896ceefa2c4c4933fcd593fa599ecbf97a4"}, {file = "black-24.8.0-cp311-cp311-win_amd64.whl", hash = "sha256:72901b4913cbac8972ad911dc4098d5753704d1f3c56e44ae8dce99eecb0e3af"}, {file = "black-24.8.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:7c046c1d1eeb7aea9335da62472481d3bbf3fd986e093cffd35f4385c94ae368"}, {file = "black-24.8.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:649f6d84ccbae73ab767e206772cc2d7a393a001070a4c814a546afd0d423aed"}, {file = "black-24.8.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2b59b250fdba5f9a9cd9d0ece6e6d993d91ce877d121d161e4698af3eb9c1018"}, {file = "black-24.8.0-cp312-cp312-win_amd64.whl", hash = "sha256:6e55d30d44bed36593c3163b9bc63bf58b3b30e4611e4d88a0c3c239930ed5b2"}, {file = "black-24.8.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:505289f17ceda596658ae81b61ebbe2d9b25aa78067035184ed0a9d855d18afd"}, {file = "black-24.8.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b19c9ad992c7883ad84c9b22aaa73562a16b819c1d8db7a1a1a49fb7ec13c7d2"}, {file = "black-24.8.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1f13f7f386f86f8121d76599114bb8c17b69d962137fc70efe56137727c7047e"}, {file = "black-24.8.0-cp38-cp38-win_amd64.whl", hash = "sha256:f490dbd59680d809ca31efdae20e634f3fae27fba3ce0ba3208333b713bc3920"}, {file = "black-24.8.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:eab4dd44ce80dea27dc69db40dab62d4ca96112f87996bca68cd75639aeb2e4c"}, {file = "black-24.8.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3c4285573d4897a7610054af5a890bde7c65cb466040c5f0c8b732812d7f0e5e"}, {file = "black-24.8.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e84e33b37be070ba135176c123ae52a51f82306def9f7d063ee302ecab2cf47"}, {file = "black-24.8.0-cp39-cp39-win_amd64.whl", hash = "sha256:73bbf84ed136e45d451a260c6b73ed674652f90a2b3211d6a35e78054563a9bb"}, {file = "black-24.8.0-py3-none-any.whl", hash = "sha256:972085c618ee94f402da1af548a4f218c754ea7e5dc70acb168bfaca4c2542ed"}, {file = "black-24.8.0.tar.gz", hash = "sha256:2500945420b6784c38b9ee885af039f5e7471ef284ab03fa35ecdde4688cd83f"}, ] [package.dependencies] click = ">=8.0.0" mypy-extensions = ">=0.4.3" packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] d = ["aiohttp (>=3.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] uvloop = ["uvloop (>=0.15.2)"] [[package]] name = "certifi" version = "2024.7.4" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, ] [[package]] name = "cffi" version = "1.17.0" description = "Foreign Function Interface for Python calling C code." optional = false python-versions = ">=3.8" files = [ {file = "cffi-1.17.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f9338cc05451f1942d0d8203ec2c346c830f8e86469903d5126c1f0a13a2bcbb"}, {file = "cffi-1.17.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:a0ce71725cacc9ebf839630772b07eeec220cbb5f03be1399e0457a1464f8e1a"}, {file = "cffi-1.17.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c815270206f983309915a6844fe994b2fa47e5d05c4c4cef267c3b30e34dbe42"}, {file = "cffi-1.17.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d6bdcd415ba87846fd317bee0774e412e8792832e7805938987e4ede1d13046d"}, {file = "cffi-1.17.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8a98748ed1a1df4ee1d6f927e151ed6c1a09d5ec21684de879c7ea6aa96f58f2"}, {file = "cffi-1.17.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0a048d4f6630113e54bb4b77e315e1ba32a5a31512c31a273807d0027a7e69ab"}, {file = "cffi-1.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:24aa705a5f5bd3a8bcfa4d123f03413de5d86e497435693b638cbffb7d5d8a1b"}, {file = "cffi-1.17.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:856bf0924d24e7f93b8aee12a3a1095c34085600aa805693fb7f5d1962393206"}, {file = "cffi-1.17.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:4304d4416ff032ed50ad6bb87416d802e67139e31c0bde4628f36a47a3164bfa"}, {file = "cffi-1.17.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:331ad15c39c9fe9186ceaf87203a9ecf5ae0ba2538c9e898e3a6967e8ad3db6f"}, {file = "cffi-1.17.0-cp310-cp310-win32.whl", hash = "sha256:669b29a9eca6146465cc574659058ed949748f0809a2582d1f1a324eb91054dc"}, {file = "cffi-1.17.0-cp310-cp310-win_amd64.whl", hash = "sha256:48b389b1fd5144603d61d752afd7167dfd205973a43151ae5045b35793232aa2"}, {file = "cffi-1.17.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:c5d97162c196ce54af6700949ddf9409e9833ef1003b4741c2b39ef46f1d9720"}, {file = "cffi-1.17.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5ba5c243f4004c750836f81606a9fcb7841f8874ad8f3bf204ff5e56332b72b9"}, {file = "cffi-1.17.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:bb9333f58fc3a2296fb1d54576138d4cf5d496a2cc118422bd77835e6ae0b9cb"}, {file = "cffi-1.17.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:435a22d00ec7d7ea533db494da8581b05977f9c37338c80bc86314bec2619424"}, {file = "cffi-1.17.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d1df34588123fcc88c872f5acb6f74ae59e9d182a2707097f9e28275ec26a12d"}, {file = "cffi-1.17.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:df8bb0010fdd0a743b7542589223a2816bdde4d94bb5ad67884348fa2c1c67e8"}, {file = "cffi-1.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8b5b9712783415695663bd463990e2f00c6750562e6ad1d28e072a611c5f2a6"}, {file = "cffi-1.17.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:ffef8fd58a36fb5f1196919638f73dd3ae0db1a878982b27a9a5a176ede4ba91"}, {file = "cffi-1.17.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:4e67d26532bfd8b7f7c05d5a766d6f437b362c1bf203a3a5ce3593a645e870b8"}, {file = "cffi-1.17.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:45f7cd36186db767d803b1473b3c659d57a23b5fa491ad83c6d40f2af58e4dbb"}, {file = "cffi-1.17.0-cp311-cp311-win32.whl", hash = "sha256:a9015f5b8af1bb6837a3fcb0cdf3b874fe3385ff6274e8b7925d81ccaec3c5c9"}, {file = "cffi-1.17.0-cp311-cp311-win_amd64.whl", hash = "sha256:b50aaac7d05c2c26dfd50c3321199f019ba76bb650e346a6ef3616306eed67b0"}, {file = "cffi-1.17.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aec510255ce690d240f7cb23d7114f6b351c733a74c279a84def763660a2c3bc"}, {file = "cffi-1.17.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2770bb0d5e3cc0e31e7318db06efcbcdb7b31bcb1a70086d3177692a02256f59"}, {file = "cffi-1.17.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:db9a30ec064129d605d0f1aedc93e00894b9334ec74ba9c6bdd08147434b33eb"}, {file = "cffi-1.17.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a47eef975d2b8b721775a0fa286f50eab535b9d56c70a6e62842134cf7841195"}, {file = "cffi-1.17.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f3e0992f23bbb0be00a921eae5363329253c3b86287db27092461c887b791e5e"}, {file = "cffi-1.17.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6107e445faf057c118d5050560695e46d272e5301feffda3c41849641222a828"}, {file = "cffi-1.17.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb862356ee9391dc5a0b3cbc00f416b48c1b9a52d252d898e5b7696a5f9fe150"}, {file = "cffi-1.17.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c1c13185b90bbd3f8b5963cd8ce7ad4ff441924c31e23c975cb150e27c2bf67a"}, {file = "cffi-1.17.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:17c6d6d3260c7f2d94f657e6872591fe8733872a86ed1345bda872cfc8c74885"}, {file = "cffi-1.17.0-cp312-cp312-win32.whl", hash = "sha256:c3b8bd3133cd50f6b637bb4322822c94c5ce4bf0d724ed5ae70afce62187c492"}, {file = "cffi-1.17.0-cp312-cp312-win_amd64.whl", hash = "sha256:dca802c8db0720ce1c49cce1149ff7b06e91ba15fa84b1d59144fef1a1bc7ac2"}, {file = "cffi-1.17.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:6ce01337d23884b21c03869d2f68c5523d43174d4fc405490eb0091057943118"}, {file = "cffi-1.17.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:cab2eba3830bf4f6d91e2d6718e0e1c14a2f5ad1af68a89d24ace0c6b17cced7"}, {file = "cffi-1.17.0-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:14b9cbc8f7ac98a739558eb86fabc283d4d564dafed50216e7f7ee62d0d25377"}, {file = "cffi-1.17.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b00e7bcd71caa0282cbe3c90966f738e2db91e64092a877c3ff7f19a1628fdcb"}, {file = "cffi-1.17.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:41f4915e09218744d8bae14759f983e466ab69b178de38066f7579892ff2a555"}, {file = "cffi-1.17.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e4760a68cab57bfaa628938e9c2971137e05ce48e762a9cb53b76c9b569f1204"}, {file = "cffi-1.17.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:011aff3524d578a9412c8b3cfaa50f2c0bd78e03eb7af7aa5e0df59b158efb2f"}, {file = "cffi-1.17.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:a003ac9edc22d99ae1286b0875c460351f4e101f8c9d9d2576e78d7e048f64e0"}, {file = "cffi-1.17.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:ef9528915df81b8f4c7612b19b8628214c65c9b7f74db2e34a646a0a2a0da2d4"}, {file = "cffi-1.17.0-cp313-cp313-win32.whl", hash = "sha256:70d2aa9fb00cf52034feac4b913181a6e10356019b18ef89bc7c12a283bf5f5a"}, {file = "cffi-1.17.0-cp313-cp313-win_amd64.whl", hash = "sha256:b7b6ea9e36d32582cda3465f54c4b454f62f23cb083ebc7a94e2ca6ef011c3a7"}, {file = "cffi-1.17.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:964823b2fc77b55355999ade496c54dde161c621cb1f6eac61dc30ed1b63cd4c"}, {file = "cffi-1.17.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:516a405f174fd3b88829eabfe4bb296ac602d6a0f68e0d64d5ac9456194a5b7e"}, {file = "cffi-1.17.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dec6b307ce928e8e112a6bb9921a1cb00a0e14979bf28b98e084a4b8a742bd9b"}, {file = "cffi-1.17.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e4094c7b464cf0a858e75cd14b03509e84789abf7b79f8537e6a72152109c76e"}, {file = "cffi-1.17.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2404f3de742f47cb62d023f0ba7c5a916c9c653d5b368cc966382ae4e57da401"}, {file = "cffi-1.17.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3aa9d43b02a0c681f0bfbc12d476d47b2b2b6a3f9287f11ee42989a268a1833c"}, {file = "cffi-1.17.0-cp38-cp38-win32.whl", hash = "sha256:0bb15e7acf8ab35ca8b24b90af52c8b391690ef5c4aec3d31f38f0d37d2cc499"}, {file = "cffi-1.17.0-cp38-cp38-win_amd64.whl", hash = "sha256:93a7350f6706b31f457c1457d3a3259ff9071a66f312ae64dc024f049055f72c"}, {file = "cffi-1.17.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:1a2ddbac59dc3716bc79f27906c010406155031a1c801410f1bafff17ea304d2"}, {file = "cffi-1.17.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6327b572f5770293fc062a7ec04160e89741e8552bf1c358d1a23eba68166759"}, {file = "cffi-1.17.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:dbc183e7bef690c9abe5ea67b7b60fdbca81aa8da43468287dae7b5c046107d4"}, {file = "cffi-1.17.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5bdc0f1f610d067c70aa3737ed06e2726fd9d6f7bfee4a351f4c40b6831f4e82"}, {file = "cffi-1.17.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6d872186c1617d143969defeadac5a904e6e374183e07977eedef9c07c8953bf"}, {file = "cffi-1.17.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0d46ee4764b88b91f16661a8befc6bfb24806d885e27436fdc292ed7e6f6d058"}, {file = "cffi-1.17.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6f76a90c345796c01d85e6332e81cab6d70de83b829cf1d9762d0a3da59c7932"}, {file = "cffi-1.17.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0e60821d312f99d3e1569202518dddf10ae547e799d75aef3bca3a2d9e8ee693"}, {file = "cffi-1.17.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:eb09b82377233b902d4c3fbeeb7ad731cdab579c6c6fda1f763cd779139e47c3"}, {file = "cffi-1.17.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:24658baf6224d8f280e827f0a50c46ad819ec8ba380a42448e24459daf809cf4"}, {file = "cffi-1.17.0-cp39-cp39-win32.whl", hash = "sha256:0fdacad9e0d9fc23e519efd5ea24a70348305e8d7d85ecbb1a5fa66dc834e7fb"}, {file = "cffi-1.17.0-cp39-cp39-win_amd64.whl", hash = "sha256:7cbc78dc018596315d4e7841c8c3a7ae31cc4d638c9b627f87d52e8abaaf2d29"}, {file = "cffi-1.17.0.tar.gz", hash = "sha256:f3157624b7558b914cb039fd1af735e5e8049a87c817cc215109ad1c8779df76"}, ] [package.dependencies] pycparser = "*" [[package]] name = "charset-normalizer" version = "3.3.2" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." optional = false python-versions = ">=3.7.0" files = [ {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"}, {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"}, {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:06435b539f889b1f6f4ac1758871aae42dc3a8c0e24ac9e60c2384973ad73027"}, {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9063e24fdb1e498ab71cb7419e24622516c4a04476b17a2dab57e8baa30d6e03"}, {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6897af51655e3691ff853668779c7bad41579facacf5fd7253b0133308cf000d"}, {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1d3193f4a680c64b4b6a9115943538edb896edc190f0b222e73761716519268e"}, {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd70574b12bb8a4d2aaa0094515df2463cb429d8536cfb6c7ce983246983e5a6"}, {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8465322196c8b4d7ab6d1e049e4c5cb460d0394da4a27d23cc242fbf0034b6b5"}, {file = "charset_normalizer-3.3.2-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a9a8e9031d613fd2009c182b69c7b2c1ef8239a0efb1df3f7c8da66d5dd3d537"}, {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:beb58fe5cdb101e3a055192ac291b7a21e3b7ef4f67fa1d74e331a7f2124341c"}, {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e06ed3eb3218bc64786f7db41917d4e686cc4856944f53d5bdf83a6884432e12"}, {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:2e81c7b9c8979ce92ed306c249d46894776a909505d8f5a4ba55b14206e3222f"}, {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:572c3763a264ba47b3cf708a44ce965d98555f618ca42c926a9c1616d8f34269"}, {file = "charset_normalizer-3.3.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519"}, {file = "charset_normalizer-3.3.2-cp310-cp310-win32.whl", hash = "sha256:3d47fa203a7bd9c5b6cee4736ee84ca03b8ef23193c0d1ca99b5089f72645c73"}, {file = "charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl", hash = "sha256:10955842570876604d404661fbccbc9c7e684caf432c09c715ec38fbae45ae09"}, {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:802fe99cca7457642125a8a88a084cef28ff0cf9407060f7b93dca5aa25480db"}, {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:573f6eac48f4769d667c4442081b1794f52919e7edada77495aaed9236d13a96"}, {file = "charset_normalizer-3.3.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:549a3a73da901d5bc3ce8d24e0600d1fa85524c10287f6004fbab87672bf3e1e"}, {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f27273b60488abe721a075bcca6d7f3964f9f6f067c8c4c605743023d7d3944f"}, {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1ceae2f17a9c33cb48e3263960dc5fc8005351ee19db217e9b1bb15d28c02574"}, {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:65f6f63034100ead094b8744b3b97965785388f308a64cf8d7c34f2f2e5be0c4"}, {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753f10e867343b4511128c6ed8c82f7bec3bd026875576dfd88483c5c73b2fd8"}, {file = "charset_normalizer-3.3.2-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4a78b2b446bd7c934f5dcedc588903fb2f5eec172f3d29e52a9096a43722adfc"}, {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e537484df0d8f426ce2afb2d0f8e1c3d0b114b83f8850e5f2fbea0e797bd82ae"}, {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:eb6904c354526e758fda7167b33005998fb68c46fbc10e013ca97f21ca5c8887"}, {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:deb6be0ac38ece9ba87dea880e438f25ca3eddfac8b002a2ec3d9183a454e8ae"}, {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:4ab2fe47fae9e0f9dee8c04187ce5d09f48eabe611be8259444906793ab7cbce"}, {file = "charset_normalizer-3.3.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:80402cd6ee291dcb72644d6eac93785fe2c8b9cb30893c1af5b8fdd753b9d40f"}, {file = "charset_normalizer-3.3.2-cp311-cp311-win32.whl", hash = "sha256:7cd13a2e3ddeed6913a65e66e94b51d80a041145a026c27e6bb76c31a853c6ab"}, {file = "charset_normalizer-3.3.2-cp311-cp311-win_amd64.whl", hash = "sha256:663946639d296df6a2bb2aa51b60a2454ca1cb29835324c640dafb5ff2131a77"}, {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:0b2b64d2bb6d3fb9112bafa732def486049e63de9618b5843bcdd081d8144cd8"}, {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:ddbb2551d7e0102e7252db79ba445cdab71b26640817ab1e3e3648dad515003b"}, {file = "charset_normalizer-3.3.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:55086ee1064215781fff39a1af09518bc9255b50d6333f2e4c74ca09fac6a8f6"}, {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8f4a014bc36d3c57402e2977dada34f9c12300af536839dc38c0beab8878f38a"}, {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a10af20b82360ab00827f916a6058451b723b4e65030c5a18577c8b2de5b3389"}, {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d756e44e94489e49571086ef83b2bb8ce311e730092d2c34ca8f7d925cb20aa"}, {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:90d558489962fd4918143277a773316e56c72da56ec7aa3dc3dbbe20fdfed15b"}, {file = "charset_normalizer-3.3.2-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ac7ffc7ad6d040517be39eb591cac5ff87416c2537df6ba3cba3bae290c0fed"}, {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:7ed9e526742851e8d5cc9e6cf41427dfc6068d4f5a3bb03659444b4cabf6bc26"}, {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8bdb58ff7ba23002a4c5808d608e4e6c687175724f54a5dade5fa8c67b604e4d"}, {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:6b3251890fff30ee142c44144871185dbe13b11bab478a88887a639655be1068"}, {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b4a23f61ce87adf89be746c8a8974fe1c823c891d8f86eb218bb957c924bb143"}, {file = "charset_normalizer-3.3.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:efcb3f6676480691518c177e3b465bcddf57cea040302f9f4e6e191af91174d4"}, {file = "charset_normalizer-3.3.2-cp312-cp312-win32.whl", hash = "sha256:d965bba47ddeec8cd560687584e88cf699fd28f192ceb452d1d7ee807c5597b7"}, {file = "charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:96b02a3dc4381e5494fad39be677abcb5e6634bf7b4fa83a6dd3112607547001"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:95f2a5796329323b8f0512e09dbb7a1860c46a39da62ecb2324f116fa8fdc85c"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c002b4ffc0be611f0d9da932eb0f704fe2602a9a949d1f738e4c34c75b0863d5"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:a981a536974bbc7a512cf44ed14938cf01030a99e9b3a06dd59578882f06f985"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3287761bc4ee9e33561a7e058c72ac0938c4f57fe49a09eae428fd88aafe7bb6"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:42cb296636fcc8b0644486d15c12376cb9fa75443e00fb25de0b8602e64c1714"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0a55554a2fa0d408816b3b5cedf0045f4b8e1a6065aec45849de2d6f3f8e9786"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:c083af607d2515612056a31f0a8d9e0fcb5876b7bfc0abad3ecd275bc4ebc2d5"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:87d1351268731db79e0f8e745d92493ee2841c974128ef629dc518b937d9194c"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:bd8f7df7d12c2db9fab40bdd87a7c09b1530128315d047a086fa3ae3435cb3a8"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:c180f51afb394e165eafe4ac2936a14bee3eb10debc9d9e4db8958fe36afe711"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8c622a5fe39a48f78944a87d4fb8a53ee07344641b0562c540d840748571b811"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-win32.whl", hash = "sha256:db364eca23f876da6f9e16c9da0df51aa4f104a972735574842618b8c6d999d4"}, {file = "charset_normalizer-3.3.2-cp37-cp37m-win_amd64.whl", hash = "sha256:86216b5cee4b06df986d214f664305142d9c76df9b6512be2738aa72a2048f99"}, {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:6463effa3186ea09411d50efc7d85360b38d5f09b870c48e4600f63af490e56a"}, {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6c4caeef8fa63d06bd437cd4bdcf3ffefe6738fb1b25951440d80dc7df8c03ac"}, {file = "charset_normalizer-3.3.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:37e55c8e51c236f95b033f6fb391d7d7970ba5fe7ff453dad675e88cf303377a"}, {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb69256e180cb6c8a894fee62b3afebae785babc1ee98b81cdf68bbca1987f33"}, {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ae5f4161f18c61806f411a13b0310bea87f987c7d2ecdbdaad0e94eb2e404238"}, {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b2b0a0c0517616b6869869f8c581d4eb2dd83a4d79e0ebcb7d373ef9956aeb0a"}, {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:45485e01ff4d3630ec0d9617310448a8702f70e9c01906b0d0118bdf9d124cf2"}, {file = "charset_normalizer-3.3.2-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:eb00ed941194665c332bf8e078baf037d6c35d7c4f3102ea2d4f16ca94a26dc8"}, {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:2127566c664442652f024c837091890cb1942c30937add288223dc895793f898"}, {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:a50aebfa173e157099939b17f18600f72f84eed3049e743b68ad15bd69b6bf99"}, {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:4d0d1650369165a14e14e1e47b372cfcb31d6ab44e6e33cb2d4e57265290044d"}, {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:923c0c831b7cfcb071580d3f46c4baf50f174be571576556269530f4bbd79d04"}, {file = "charset_normalizer-3.3.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:06a81e93cd441c56a9b65d8e1d043daeb97a3d0856d177d5c90ba85acb3db087"}, {file = "charset_normalizer-3.3.2-cp38-cp38-win32.whl", hash = "sha256:6ef1d82a3af9d3eecdba2321dc1b3c238245d890843e040e41e470ffa64c3e25"}, {file = "charset_normalizer-3.3.2-cp38-cp38-win_amd64.whl", hash = "sha256:eb8821e09e916165e160797a6c17edda0679379a4be5c716c260e836e122f54b"}, {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:c235ebd9baae02f1b77bcea61bce332cb4331dc3617d254df3323aa01ab47bd4"}, {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:5b4c145409bef602a690e7cfad0a15a55c13320ff7a3ad7ca59c13bb8ba4d45d"}, {file = "charset_normalizer-3.3.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:68d1f8a9e9e37c1223b656399be5d6b448dea850bed7d0f87a8311f1ff3dabb0"}, {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:22afcb9f253dac0696b5a4be4a1c0f8762f8239e21b99680099abd9b2b1b2269"}, {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e27ad930a842b4c5eb8ac0016b0a54f5aebbe679340c26101df33424142c143c"}, {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1f79682fbe303db92bc2b1136016a38a42e835d932bab5b3b1bfcfbf0640e519"}, {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b261ccdec7821281dade748d088bb6e9b69e6d15b30652b74cbbac25e280b796"}, {file = "charset_normalizer-3.3.2-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:122c7fa62b130ed55f8f285bfd56d5f4b4a5b503609d181f9ad85e55c89f4185"}, {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:d0eccceffcb53201b5bfebb52600a5fb483a20b61da9dbc885f8b103cbe7598c"}, {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:9f96df6923e21816da7e0ad3fd47dd8f94b2a5ce594e00677c0013018b813458"}, {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:7f04c839ed0b6b98b1a7501a002144b76c18fb1c1850c8b98d458ac269e26ed2"}, {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:34d1c8da1e78d2e001f363791c98a272bb734000fcef47a491c1e3b0505657a8"}, {file = "charset_normalizer-3.3.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561"}, {file = "charset_normalizer-3.3.2-cp39-cp39-win32.whl", hash = "sha256:aed38f6e4fb3f5d6bf81bfa990a07806be9d83cf7bacef998ab1a9bd660a581f"}, {file = "charset_normalizer-3.3.2-cp39-cp39-win_amd64.whl", hash = "sha256:b01b88d45a6fcb69667cd6d2f7a9aeb4bf53760d7fc536bf679ec94fe9f3ff3d"}, {file = "charset_normalizer-3.3.2-py3-none-any.whl", hash = "sha256:3e4d1f6587322d2788836a99c69062fbb091331ec940e02d12d179c1d53e25fc"}, ] [[package]] name = "click" version = "8.1.7" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.7" files = [ {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, ] [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} [[package]] name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] [[package]] name = "colorful" version = "0.5.6" description = "Terminal string styling done right, in Python." optional = false python-versions = "*" files = [ {file = "colorful-0.5.6-py2.py3-none-any.whl", hash = "sha256:eab8c1c809f5025ad2b5238a50bd691e26850da8cac8f90d660ede6ea1af9f1e"}, {file = "colorful-0.5.6.tar.gz", hash = "sha256:b56d5c01db1dac4898308ea889edcb113fbee3e6ec5df4bacffd61d5241b5b8d"}, ] [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} [[package]] name = "coverage" version = "7.6.1" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" files = [ {file = "coverage-7.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b06079abebbc0e89e6163b8e8f0e16270124c154dc6e4a47b413dd538859af16"}, {file = "coverage-7.6.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:cf4b19715bccd7ee27b6b120e7e9dd56037b9c0681dcc1adc9ba9db3d417fa36"}, {file = "coverage-7.6.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e61c0abb4c85b095a784ef23fdd4aede7a2628478e7baba7c5e3deba61070a02"}, {file = "coverage-7.6.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:fd21f6ae3f08b41004dfb433fa895d858f3f5979e7762d052b12aef444e29afc"}, {file = "coverage-7.6.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8f59d57baca39b32db42b83b2a7ba6f47ad9c394ec2076b084c3f029b7afca23"}, {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:a1ac0ae2b8bd743b88ed0502544847c3053d7171a3cff9228af618a068ed9c34"}, {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:e6a08c0be454c3b3beb105c0596ebdc2371fab6bb90c0c0297f4e58fd7e1012c"}, {file = "coverage-7.6.1-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:f5796e664fe802da4f57a168c85359a8fbf3eab5e55cd4e4569fbacecc903959"}, {file = "coverage-7.6.1-cp310-cp310-win32.whl", hash = "sha256:7bb65125fcbef8d989fa1dd0e8a060999497629ca5b0efbca209588a73356232"}, {file = "coverage-7.6.1-cp310-cp310-win_amd64.whl", hash = "sha256:3115a95daa9bdba70aea750db7b96b37259a81a709223c8448fa97727d546fe0"}, {file = "coverage-7.6.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:7dea0889685db8550f839fa202744652e87c60015029ce3f60e006f8c4462c93"}, {file = "coverage-7.6.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ed37bd3c3b063412f7620464a9ac1314d33100329f39799255fb8d3027da50d3"}, {file = "coverage-7.6.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d85f5e9a5f8b73e2350097c3756ef7e785f55bd71205defa0bfdaf96c31616ff"}, {file = "coverage-7.6.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9bc572be474cafb617672c43fe989d6e48d3c83af02ce8de73fff1c6bb3c198d"}, {file = "coverage-7.6.1-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0c0420b573964c760df9e9e86d1a9a622d0d27f417e1a949a8a66dd7bcee7bc6"}, {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1f4aa8219db826ce6be7099d559f8ec311549bfc4046f7f9fe9b5cea5c581c56"}, {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:fc5a77d0c516700ebad189b587de289a20a78324bc54baee03dd486f0855d234"}, {file = "coverage-7.6.1-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:b48f312cca9621272ae49008c7f613337c53fadca647d6384cc129d2996d1133"}, {file = "coverage-7.6.1-cp311-cp311-win32.whl", hash = "sha256:1125ca0e5fd475cbbba3bb67ae20bd2c23a98fac4e32412883f9bcbaa81c314c"}, {file = "coverage-7.6.1-cp311-cp311-win_amd64.whl", hash = "sha256:8ae539519c4c040c5ffd0632784e21b2f03fc1340752af711f33e5be83a9d6c6"}, {file = "coverage-7.6.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:95cae0efeb032af8458fc27d191f85d1717b1d4e49f7cb226cf526ff28179778"}, {file = "coverage-7.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:5621a9175cf9d0b0c84c2ef2b12e9f5f5071357c4d2ea6ca1cf01814f45d2391"}, {file = "coverage-7.6.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:260933720fdcd75340e7dbe9060655aff3af1f0c5d20f46b57f262ab6c86a5e8"}, {file = "coverage-7.6.1-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:07e2ca0ad381b91350c0ed49d52699b625aab2b44b65e1b4e02fa9df0e92ad2d"}, {file = "coverage-7.6.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c44fee9975f04b33331cb8eb272827111efc8930cfd582e0320613263ca849ca"}, {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:877abb17e6339d96bf08e7a622d05095e72b71f8afd8a9fefc82cf30ed944163"}, {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:3e0cadcf6733c09154b461f1ca72d5416635e5e4ec4e536192180d34ec160f8a"}, {file = "coverage-7.6.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:c3c02d12f837d9683e5ab2f3d9844dc57655b92c74e286c262e0fc54213c216d"}, {file = "coverage-7.6.1-cp312-cp312-win32.whl", hash = "sha256:e05882b70b87a18d937ca6768ff33cc3f72847cbc4de4491c8e73880766718e5"}, {file = "coverage-7.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:b5d7b556859dd85f3a541db6a4e0167b86e7273e1cdc973e5b175166bb634fdb"}, {file = "coverage-7.6.1-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a4acd025ecc06185ba2b801f2de85546e0b8ac787cf9d3b06e7e2a69f925b106"}, {file = "coverage-7.6.1-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:a6d3adcf24b624a7b778533480e32434a39ad8fa30c315208f6d3e5542aeb6e9"}, {file = "coverage-7.6.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d0c212c49b6c10e6951362f7c6df3329f04c2b1c28499563d4035d964ab8e08c"}, {file = "coverage-7.6.1-cp313-cp313-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6e81d7a3e58882450ec4186ca59a3f20a5d4440f25b1cff6f0902ad890e6748a"}, {file = "coverage-7.6.1-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78b260de9790fd81e69401c2dc8b17da47c8038176a79092a89cb2b7d945d060"}, {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a78d169acd38300060b28d600344a803628c3fd585c912cacc9ea8790fe96862"}, {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_i686.whl", hash = "sha256:2c09f4ce52cb99dd7505cd0fc8e0e37c77b87f46bc9c1eb03fe3bc9991085388"}, {file = "coverage-7.6.1-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:6878ef48d4227aace338d88c48738a4258213cd7b74fd9a3d4d7582bb1d8a155"}, {file = "coverage-7.6.1-cp313-cp313-win32.whl", hash = "sha256:44df346d5215a8c0e360307d46ffaabe0f5d3502c8a1cefd700b34baf31d411a"}, {file = "coverage-7.6.1-cp313-cp313-win_amd64.whl", hash = "sha256:8284cf8c0dd272a247bc154eb6c95548722dce90d098c17a883ed36e67cdb129"}, {file = "coverage-7.6.1-cp313-cp313t-macosx_10_13_x86_64.whl", hash = "sha256:d3296782ca4eab572a1a4eca686d8bfb00226300dcefdf43faa25b5242ab8a3e"}, {file = "coverage-7.6.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:502753043567491d3ff6d08629270127e0c31d4184c4c8d98f92c26f65019962"}, {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6a89ecca80709d4076b95f89f308544ec8f7b4727e8a547913a35f16717856cb"}, {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a318d68e92e80af8b00fa99609796fdbcdfef3629c77c6283566c6f02c6d6704"}, {file = "coverage-7.6.1-cp313-cp313t-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:13b0a73a0896988f053e4fbb7de6d93388e6dd292b0d87ee51d106f2c11b465b"}, {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_aarch64.whl", hash = "sha256:4421712dbfc5562150f7554f13dde997a2e932a6b5f352edcce948a815efee6f"}, {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_i686.whl", hash = "sha256:166811d20dfea725e2e4baa71fffd6c968a958577848d2131f39b60043400223"}, {file = "coverage-7.6.1-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:225667980479a17db1048cb2bf8bfb39b8e5be8f164b8f6628b64f78a72cf9d3"}, {file = "coverage-7.6.1-cp313-cp313t-win32.whl", hash = "sha256:170d444ab405852903b7d04ea9ae9b98f98ab6d7e63e1115e82620807519797f"}, {file = "coverage-7.6.1-cp313-cp313t-win_amd64.whl", hash = "sha256:b9f222de8cded79c49bf184bdbc06630d4c58eec9459b939b4a690c82ed05657"}, {file = "coverage-7.6.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:6db04803b6c7291985a761004e9060b2bca08da6d04f26a7f2294b8623a0c1a0"}, {file = "coverage-7.6.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f1adfc8ac319e1a348af294106bc6a8458a0f1633cc62a1446aebc30c5fa186a"}, {file = "coverage-7.6.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a95324a9de9650a729239daea117df21f4b9868ce32e63f8b650ebe6cef5595b"}, {file = "coverage-7.6.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b43c03669dc4618ec25270b06ecd3ee4fa94c7f9b3c14bae6571ca00ef98b0d3"}, {file = "coverage-7.6.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8929543a7192c13d177b770008bc4e8119f2e1f881d563fc6b6305d2d0ebe9de"}, {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:a09ece4a69cf399510c8ab25e0950d9cf2b42f7b3cb0374f95d2e2ff594478a6"}, {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:9054a0754de38d9dbd01a46621636689124d666bad1936d76c0341f7d71bf569"}, {file = "coverage-7.6.1-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:0dbde0f4aa9a16fa4d754356a8f2e36296ff4d83994b2c9d8398aa32f222f989"}, {file = "coverage-7.6.1-cp38-cp38-win32.whl", hash = "sha256:da511e6ad4f7323ee5702e6633085fb76c2f893aaf8ce4c51a0ba4fc07580ea7"}, {file = "coverage-7.6.1-cp38-cp38-win_amd64.whl", hash = "sha256:3f1156e3e8f2872197af3840d8ad307a9dd18e615dc64d9ee41696f287c57ad8"}, {file = "coverage-7.6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:abd5fd0db5f4dc9289408aaf34908072f805ff7792632250dcb36dc591d24255"}, {file = "coverage-7.6.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:547f45fa1a93154bd82050a7f3cddbc1a7a4dd2a9bf5cb7d06f4ae29fe94eaf8"}, {file = "coverage-7.6.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:645786266c8f18a931b65bfcefdbf6952dd0dea98feee39bd188607a9d307ed2"}, {file = "coverage-7.6.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9e0b2df163b8ed01d515807af24f63de04bebcecbd6c3bfeff88385789fdf75a"}, {file = "coverage-7.6.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:609b06f178fe8e9f89ef676532760ec0b4deea15e9969bf754b37f7c40326dbc"}, {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:702855feff378050ae4f741045e19a32d57d19f3e0676d589df0575008ea5004"}, {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:2bdb062ea438f22d99cba0d7829c2ef0af1d768d1e4a4f528087224c90b132cb"}, {file = "coverage-7.6.1-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:9c56863d44bd1c4fe2abb8a4d6f5371d197f1ac0ebdee542f07f35895fc07f36"}, {file = "coverage-7.6.1-cp39-cp39-win32.whl", hash = "sha256:6e2cd258d7d927d09493c8df1ce9174ad01b381d4729a9d8d4e38670ca24774c"}, {file = "coverage-7.6.1-cp39-cp39-win_amd64.whl", hash = "sha256:06a737c882bd26d0d6ee7269b20b12f14a8704807a01056c80bb881a4b2ce6ca"}, {file = "coverage-7.6.1-pp38.pp39.pp310-none-any.whl", hash = "sha256:e9a6e0eb86070e8ccaedfbd9d38fec54864f3125ab95419970575b42af7541df"}, {file = "coverage-7.6.1.tar.gz", hash = "sha256:953510dfb7b12ab69d20135a0662397f077c59b1e6379a768e97c59d852ee51d"}, ] [package.extras] toml = ["tomli"] [[package]] name = "cryptography" version = "43.0.0" description = "cryptography is a package which provides cryptographic recipes and primitives to Python developers." optional = false python-versions = ">=3.7" files = [ {file = "cryptography-43.0.0-cp37-abi3-macosx_10_9_universal2.whl", hash = "sha256:64c3f16e2a4fc51c0d06af28441881f98c5d91009b8caaff40cf3548089e9c74"}, {file = "cryptography-43.0.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3dcdedae5c7710b9f97ac6bba7e1052b95c7083c9d0e9df96e02a1932e777895"}, {file = "cryptography-43.0.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d9a1eca329405219b605fac09ecfc09ac09e595d6def650a437523fcd08dd22"}, {file = "cryptography-43.0.0-cp37-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:ea9e57f8ea880eeea38ab5abf9fbe39f923544d7884228ec67d666abd60f5a47"}, {file = "cryptography-43.0.0-cp37-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:9a8d6802e0825767476f62aafed40532bd435e8a5f7d23bd8b4f5fd04cc80ecf"}, {file = "cryptography-43.0.0-cp37-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:cc70b4b581f28d0a254d006f26949245e3657d40d8857066c2ae22a61222ef55"}, {file = "cryptography-43.0.0-cp37-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:4a997df8c1c2aae1e1e5ac49c2e4f610ad037fc5a3aadc7b64e39dea42249431"}, {file = "cryptography-43.0.0-cp37-abi3-win32.whl", hash = "sha256:6e2b11c55d260d03a8cf29ac9b5e0608d35f08077d8c087be96287f43af3ccdc"}, {file = "cryptography-43.0.0-cp37-abi3-win_amd64.whl", hash = "sha256:31e44a986ceccec3d0498e16f3d27b2ee5fdf69ce2ab89b52eaad1d2f33d8778"}, {file = "cryptography-43.0.0-cp39-abi3-macosx_10_9_universal2.whl", hash = "sha256:7b3f5fe74a5ca32d4d0f302ffe6680fcc5c28f8ef0dc0ae8f40c0f3a1b4fca66"}, {file = "cryptography-43.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ac1955ce000cb29ab40def14fd1bbfa7af2017cca696ee696925615cafd0dce5"}, {file = "cryptography-43.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:299d3da8e00b7e2b54bb02ef58d73cd5f55fb31f33ebbf33bd00d9aa6807df7e"}, {file = "cryptography-43.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:ee0c405832ade84d4de74b9029bedb7b31200600fa524d218fc29bfa371e97f5"}, {file = "cryptography-43.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:cb013933d4c127349b3948aa8aaf2f12c0353ad0eccd715ca789c8a0f671646f"}, {file = "cryptography-43.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:fdcb265de28585de5b859ae13e3846a8e805268a823a12a4da2597f1f5afc9f0"}, {file = "cryptography-43.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:2905ccf93a8a2a416f3ec01b1a7911c3fe4073ef35640e7ee5296754e30b762b"}, {file = "cryptography-43.0.0-cp39-abi3-win32.whl", hash = "sha256:47ca71115e545954e6c1d207dd13461ab81f4eccfcb1345eac874828b5e3eaaf"}, {file = "cryptography-43.0.0-cp39-abi3-win_amd64.whl", hash = "sha256:0663585d02f76929792470451a5ba64424acc3cd5227b03921dab0e2f27b1709"}, {file = "cryptography-43.0.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:2c6d112bf61c5ef44042c253e4859b3cbbb50df2f78fa8fae6747a7814484a70"}, {file = "cryptography-43.0.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:844b6d608374e7d08f4f6e6f9f7b951f9256db41421917dfb2d003dde4cd6b66"}, {file = "cryptography-43.0.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:51956cf8730665e2bdf8ddb8da0056f699c1a5715648c1b0144670c1ba00b48f"}, {file = "cryptography-43.0.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:aae4d918f6b180a8ab8bf6511a419473d107df4dbb4225c7b48c5c9602c38c7f"}, {file = "cryptography-43.0.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:232ce02943a579095a339ac4b390fbbe97f5b5d5d107f8a08260ea2768be8cc2"}, {file = "cryptography-43.0.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:5bcb8a5620008a8034d39bce21dc3e23735dfdb6a33a06974739bfa04f853947"}, {file = "cryptography-43.0.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:08a24a7070b2b6804c1940ff0f910ff728932a9d0e80e7814234269f9d46d069"}, {file = "cryptography-43.0.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:e9c5266c432a1e23738d178e51c2c7a5e2ddf790f248be939448c0ba2021f9d1"}, {file = "cryptography-43.0.0.tar.gz", hash = "sha256:b88075ada2d51aa9f18283532c9f60e72170041bba88d7f37e49cbb10275299e"}, ] [package.dependencies] cffi = {version = ">=1.12", markers = "platform_python_implementation != \"PyPy\""} [package.extras] docs = ["sphinx (>=5.3.0)", "sphinx-rtd-theme (>=1.1.1)"] docstest = ["pyenchant (>=1.6.11)", "readme-renderer", "sphinxcontrib-spelling (>=4.0.1)"] nox = ["nox"] pep8test = ["check-sdist", "click", "mypy", "ruff"] sdist = ["build"] ssh = ["bcrypt (>=3.1.5)"] test = ["certifi", "cryptography-vectors (==43.0.0)", "pretend", "pytest (>=6.2.0)", "pytest-benchmark", "pytest-cov", "pytest-xdist"] test-randomorder = ["pytest-randomly"] [[package]] name = "docutils" version = "0.21.2" description = "Docutils -- Python Documentation Utilities" optional = false python-versions = ">=3.9" files = [ {file = "docutils-0.21.2-py3-none-any.whl", hash = "sha256:dafca5b9e384f0e419294eb4d2ff9fa826435bf15f15b7bd45723e8ad76811b2"}, {file = "docutils-0.21.2.tar.gz", hash = "sha256:3a6b18732edf182daa3cd12775bbb338cf5691468f91eeeb109deff6ebfa986f"}, ] [[package]] name = "exceptiongroup" version = "1.2.2" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, {file = "exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc"}, ] [package.extras] test = ["pytest (>=6)"] [[package]] name = "furo" version = "2024.8.6" description = "A clean customisable Sphinx documentation theme." optional = false python-versions = ">=3.8" files = [ {file = "furo-2024.8.6-py3-none-any.whl", hash = "sha256:6cd97c58b47813d3619e63e9081169880fbe331f0ca883c871ff1f3f11814f5c"}, {file = "furo-2024.8.6.tar.gz", hash = "sha256:b63e4cee8abfc3136d3bc03a3d45a76a850bada4d6374d24c1716b0e01394a01"}, ] [package.dependencies] beautifulsoup4 = "*" pygments = ">=2.7" sphinx = ">=6.0,<9.0" sphinx-basic-ng = ">=1.0.0.beta2" [[package]] name = "h11" version = "0.14.0" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" optional = false python-versions = ">=3.7" files = [ {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, ] [[package]] name = "h2" version = "4.1.0" description = "HTTP/2 State-Machine based protocol implementation" optional = false python-versions = ">=3.6.1" files = [ {file = "h2-4.1.0-py3-none-any.whl", hash = "sha256:03a46bcf682256c95b5fd9e9a99c1323584c3eec6440d379b9903d709476bc6d"}, {file = "h2-4.1.0.tar.gz", hash = "sha256:a83aca08fbe7aacb79fec788c9c0bac936343560ed9ec18b82a13a12c28d2abb"}, ] [package.dependencies] hpack = ">=4.0,<5" hyperframe = ">=6.0,<7" [[package]] name = "hpack" version = "4.0.0" description = "Pure-Python HPACK header compression" optional = false python-versions = ">=3.6.1" files = [ {file = "hpack-4.0.0-py3-none-any.whl", hash = "sha256:84a076fad3dc9a9f8063ccb8041ef100867b1878b25ef0ee63847a5d53818a6c"}, {file = "hpack-4.0.0.tar.gz", hash = "sha256:fc41de0c63e687ebffde81187a948221294896f6bdc0ae2312708df339430095"}, ] [[package]] name = "httpcore" version = "1.0.5" description = "A minimal low-level HTTP client." optional = false python-versions = ">=3.8" files = [ {file = "httpcore-1.0.5-py3-none-any.whl", hash = "sha256:421f18bac248b25d310f3cacd198d55b8e6125c107797b609ff9b7a6ba7991b5"}, {file = "httpcore-1.0.5.tar.gz", hash = "sha256:34a38e2f9291467ee3b44e89dd52615370e152954ba21721378a87b2960f7a61"}, ] [package.dependencies] certifi = "*" h11 = ">=0.13,<0.15" [package.extras] asyncio = ["anyio (>=4.0,<5.0)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] trio = ["trio (>=0.22.0,<0.26.0)"] [[package]] name = "httpx" version = "0.27.0" description = "The next generation HTTP client." optional = false python-versions = ">=3.8" files = [ {file = "httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5"}, {file = "httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5"}, ] [package.dependencies] anyio = "*" certifi = "*" h2 = {version = ">=3,<5", optional = true, markers = "extra == \"http2\""} httpcore = "==1.*" idna = "*" sniffio = "*" [package.extras] brotli = ["brotli", "brotlicffi"] cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] [[package]] name = "hyperframe" version = "6.0.1" description = "HTTP/2 framing layer for Python" optional = false python-versions = ">=3.6.1" files = [ {file = "hyperframe-6.0.1-py3-none-any.whl", hash = "sha256:0ec6bafd80d8ad2195c4f03aacba3a8265e57bc4cff261e802bf39970ed02a15"}, {file = "hyperframe-6.0.1.tar.gz", hash = "sha256:ae510046231dc8e9ecb1a6586f63d2347bf4c8905914aa84ba585ae85f28a914"}, ] [[package]] name = "idna" version = "3.8" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.6" files = [ {file = "idna-3.8-py3-none-any.whl", hash = "sha256:050b4e5baadcd44d760cedbd2b8e639f2ff89bbc7a5730fcc662954303377aac"}, {file = "idna-3.8.tar.gz", hash = "sha256:d838c2c0ed6fced7693d5e8ab8e734d5f8fda53a039c0164afb0b82e771e3603"}, ] [[package]] name = "imagesize" version = "1.4.1" description = "Getting image size from png/jpeg/jpeg2000/gif file" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ {file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"}, {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, ] [[package]] name = "importlib-metadata" version = "8.4.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" files = [ {file = "importlib_metadata-8.4.0-py3-none-any.whl", hash = "sha256:66f342cc6ac9818fc6ff340576acd24d65ba0b3efabb2b4ac08b598965a4a2f1"}, {file = "importlib_metadata-8.4.0.tar.gz", hash = "sha256:9a547d3bc3608b025f93d403fdd1aae741c24fbb8314df4b155675742ce303c5"}, ] [package.dependencies] zipp = ">=0.5" [package.extras] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] perf = ["ipython"] test = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] [[package]] name = "jinja2" version = "3.1.4" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" files = [ {file = "jinja2-3.1.4-py3-none-any.whl", hash = "sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d"}, {file = "jinja2-3.1.4.tar.gz", hash = "sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369"}, ] [package.dependencies] MarkupSafe = ">=2.0" [package.extras] i18n = ["Babel (>=2.7)"] [[package]] name = "lxml" version = "5.3.0" description = "Powerful and Pythonic XML processing library combining libxml2/libxslt with the ElementTree API." optional = false python-versions = ">=3.6" files = [ {file = "lxml-5.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:dd36439be765e2dde7660212b5275641edbc813e7b24668831a5c8ac91180656"}, {file = "lxml-5.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:ae5fe5c4b525aa82b8076c1a59d642c17b6e8739ecf852522c6321852178119d"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:501d0d7e26b4d261fca8132854d845e4988097611ba2531408ec91cf3fd9d20a"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fb66442c2546446944437df74379e9cf9e9db353e61301d1a0e26482f43f0dd8"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9e41506fec7a7f9405b14aa2d5c8abbb4dbbd09d88f9496958b6d00cb4d45330"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f7d4a670107d75dfe5ad080bed6c341d18c4442f9378c9f58e5851e86eb79965"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:41ce1f1e2c7755abfc7e759dc34d7d05fd221723ff822947132dc934d122fe22"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:44264ecae91b30e5633013fb66f6ddd05c006d3e0e884f75ce0b4755b3e3847b"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_28_ppc64le.whl", hash = "sha256:3c174dc350d3ec52deb77f2faf05c439331d6ed5e702fc247ccb4e6b62d884b7"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_28_s390x.whl", hash = "sha256:2dfab5fa6a28a0b60a20638dc48e6343c02ea9933e3279ccb132f555a62323d8"}, {file = "lxml-5.3.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:b1c8c20847b9f34e98080da785bb2336ea982e7f913eed5809e5a3c872900f32"}, {file = "lxml-5.3.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:2c86bf781b12ba417f64f3422cfc302523ac9cd1d8ae8c0f92a1c66e56ef2e86"}, {file = "lxml-5.3.0-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:c162b216070f280fa7da844531169be0baf9ccb17263cf5a8bf876fcd3117fa5"}, {file = "lxml-5.3.0-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:36aef61a1678cb778097b4a6eeae96a69875d51d1e8f4d4b491ab3cfb54b5a03"}, {file = "lxml-5.3.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:f65e5120863c2b266dbcc927b306c5b78e502c71edf3295dfcb9501ec96e5fc7"}, {file = "lxml-5.3.0-cp310-cp310-win32.whl", hash = "sha256:ef0c1fe22171dd7c7c27147f2e9c3e86f8bdf473fed75f16b0c2e84a5030ce80"}, {file = "lxml-5.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:052d99051e77a4f3e8482c65014cf6372e61b0a6f4fe9edb98503bb5364cfee3"}, {file = "lxml-5.3.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:74bcb423462233bc5d6066e4e98b0264e7c1bed7541fff2f4e34fe6b21563c8b"}, {file = "lxml-5.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:a3d819eb6f9b8677f57f9664265d0a10dd6551d227afb4af2b9cd7bdc2ccbf18"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5b8f5db71b28b8c404956ddf79575ea77aa8b1538e8b2ef9ec877945b3f46442"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2c3406b63232fc7e9b8783ab0b765d7c59e7c59ff96759d8ef9632fca27c7ee4"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2ecdd78ab768f844c7a1d4a03595038c166b609f6395e25af9b0f3f26ae1230f"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:168f2dfcfdedf611eb285efac1516c8454c8c99caf271dccda8943576b67552e"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:aa617107a410245b8660028a7483b68e7914304a6d4882b5ff3d2d3eb5948d8c"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:69959bd3167b993e6e710b99051265654133a98f20cec1d9b493b931942e9c16"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_28_ppc64le.whl", hash = "sha256:bd96517ef76c8654446fc3db9242d019a1bb5fe8b751ba414765d59f99210b79"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_28_s390x.whl", hash = "sha256:ab6dd83b970dc97c2d10bc71aa925b84788c7c05de30241b9e96f9b6d9ea3080"}, {file = "lxml-5.3.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:eec1bb8cdbba2925bedc887bc0609a80e599c75b12d87ae42ac23fd199445654"}, {file = "lxml-5.3.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:6a7095eeec6f89111d03dabfe5883a1fd54da319c94e0fb104ee8f23616b572d"}, {file = "lxml-5.3.0-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:6f651ebd0b21ec65dfca93aa629610a0dbc13dbc13554f19b0113da2e61a4763"}, {file = "lxml-5.3.0-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:f422a209d2455c56849442ae42f25dbaaba1c6c3f501d58761c619c7836642ec"}, {file = "lxml-5.3.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:62f7fdb0d1ed2065451f086519865b4c90aa19aed51081979ecd05a21eb4d1be"}, {file = "lxml-5.3.0-cp311-cp311-win32.whl", hash = "sha256:c6379f35350b655fd817cd0d6cbeef7f265f3ae5fedb1caae2eb442bbeae9ab9"}, {file = "lxml-5.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:9c52100e2c2dbb0649b90467935c4b0de5528833c76a35ea1a2691ec9f1ee7a1"}, {file = "lxml-5.3.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:e99f5507401436fdcc85036a2e7dc2e28d962550afe1cbfc07c40e454256a859"}, {file = "lxml-5.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:384aacddf2e5813a36495233b64cb96b1949da72bef933918ba5c84e06af8f0e"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:874a216bf6afaf97c263b56371434e47e2c652d215788396f60477540298218f"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:65ab5685d56914b9a2a34d67dd5488b83213d680b0c5d10b47f81da5a16b0b0e"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:aac0bbd3e8dd2d9c45ceb82249e8bdd3ac99131a32b4d35c8af3cc9db1657179"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b369d3db3c22ed14c75ccd5af429086f166a19627e84a8fdade3f8f31426e52a"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c24037349665434f375645fa9d1f5304800cec574d0310f618490c871fd902b3"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:62d172f358f33a26d6b41b28c170c63886742f5b6772a42b59b4f0fa10526cb1"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_28_ppc64le.whl", hash = "sha256:c1f794c02903c2824fccce5b20c339a1a14b114e83b306ff11b597c5f71a1c8d"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_28_s390x.whl", hash = "sha256:5d6a6972b93c426ace71e0be9a6f4b2cfae9b1baed2eed2006076a746692288c"}, {file = "lxml-5.3.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:3879cc6ce938ff4eb4900d901ed63555c778731a96365e53fadb36437a131a99"}, {file = "lxml-5.3.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:74068c601baff6ff021c70f0935b0c7bc528baa8ea210c202e03757c68c5a4ff"}, {file = "lxml-5.3.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:ecd4ad8453ac17bc7ba3868371bffb46f628161ad0eefbd0a855d2c8c32dd81a"}, {file = "lxml-5.3.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:7e2f58095acc211eb9d8b5771bf04df9ff37d6b87618d1cbf85f92399c98dae8"}, {file = "lxml-5.3.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:e63601ad5cd8f860aa99d109889b5ac34de571c7ee902d6812d5d9ddcc77fa7d"}, {file = "lxml-5.3.0-cp312-cp312-win32.whl", hash = "sha256:17e8d968d04a37c50ad9c456a286b525d78c4a1c15dd53aa46c1d8e06bf6fa30"}, {file = "lxml-5.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:c1a69e58a6bb2de65902051d57fde951febad631a20a64572677a1052690482f"}, {file = "lxml-5.3.0-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:8c72e9563347c7395910de6a3100a4840a75a6f60e05af5e58566868d5eb2d6a"}, {file = "lxml-5.3.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:e92ce66cd919d18d14b3856906a61d3f6b6a8500e0794142338da644260595cd"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1d04f064bebdfef9240478f7a779e8c5dc32b8b7b0b2fc6a62e39b928d428e51"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5c2fb570d7823c2bbaf8b419ba6e5662137f8166e364a8b2b91051a1fb40ab8b"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0c120f43553ec759f8de1fee2f4794452b0946773299d44c36bfe18e83caf002"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:562e7494778a69086f0312ec9689f6b6ac1c6b65670ed7d0267e49f57ffa08c4"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:423b121f7e6fa514ba0c7918e56955a1d4470ed35faa03e3d9f0e3baa4c7e492"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_28_aarch64.whl", hash = "sha256:c00f323cc00576df6165cc9d21a4c21285fa6b9989c5c39830c3903dc4303ef3"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_28_ppc64le.whl", hash = "sha256:1fdc9fae8dd4c763e8a31e7630afef517eab9f5d5d31a278df087f307bf601f4"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_28_s390x.whl", hash = "sha256:658f2aa69d31e09699705949b5fc4719cbecbd4a97f9656a232e7d6c7be1a367"}, {file = "lxml-5.3.0-cp313-cp313-manylinux_2_28_x86_64.whl", hash = "sha256:1473427aff3d66a3fa2199004c3e601e6c4500ab86696edffdbc84954c72d832"}, {file = "lxml-5.3.0-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:a87de7dd873bf9a792bf1e58b1c3887b9264036629a5bf2d2e6579fe8e73edff"}, {file = "lxml-5.3.0-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:0d7b36afa46c97875303a94e8f3ad932bf78bace9e18e603f2085b652422edcd"}, {file = "lxml-5.3.0-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:cf120cce539453ae086eacc0130a324e7026113510efa83ab42ef3fcfccac7fb"}, {file = "lxml-5.3.0-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:df5c7333167b9674aa8ae1d4008fa4bc17a313cc490b2cca27838bbdcc6bb15b"}, {file = "lxml-5.3.0-cp313-cp313-win32.whl", hash = "sha256:c802e1c2ed9f0c06a65bc4ed0189d000ada8049312cfeab6ca635e39c9608957"}, {file = "lxml-5.3.0-cp313-cp313-win_amd64.whl", hash = "sha256:406246b96d552e0503e17a1006fd27edac678b3fcc9f1be71a2f94b4ff61528d"}, {file = "lxml-5.3.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:8f0de2d390af441fe8b2c12626d103540b5d850d585b18fcada58d972b74a74e"}, {file = "lxml-5.3.0-cp36-cp36m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1afe0a8c353746e610bd9031a630a95bcfb1a720684c3f2b36c4710a0a96528f"}, {file = "lxml-5.3.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:56b9861a71575f5795bde89256e7467ece3d339c9b43141dbdd54544566b3b94"}, {file = "lxml-5.3.0-cp36-cp36m-manylinux_2_28_x86_64.whl", hash = "sha256:9fb81d2824dff4f2e297a276297e9031f46d2682cafc484f49de182aa5e5df99"}, {file = "lxml-5.3.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl", hash = "sha256:2c226a06ecb8cdef28845ae976da407917542c5e6e75dcac7cc33eb04aaeb237"}, {file = "lxml-5.3.0-cp36-cp36m-musllinux_1_2_x86_64.whl", hash = "sha256:7d3d1ca42870cdb6d0d29939630dbe48fa511c203724820fc0fd507b2fb46577"}, {file = "lxml-5.3.0-cp36-cp36m-win32.whl", hash = "sha256:094cb601ba9f55296774c2d57ad68730daa0b13dc260e1f941b4d13678239e70"}, {file = "lxml-5.3.0-cp36-cp36m-win_amd64.whl", hash = "sha256:eafa2c8658f4e560b098fe9fc54539f86528651f61849b22111a9b107d18910c"}, {file = "lxml-5.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cb83f8a875b3d9b458cada4f880fa498646874ba4011dc974e071a0a84a1b033"}, {file = "lxml-5.3.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:25f1b69d41656b05885aa185f5fdf822cb01a586d1b32739633679699f220391"}, {file = "lxml-5.3.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:23e0553b8055600b3bf4a00b255ec5c92e1e4aebf8c2c09334f8368e8bd174d6"}, {file = "lxml-5.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9ada35dd21dc6c039259596b358caab6b13f4db4d4a7f8665764d616daf9cc1d"}, {file = "lxml-5.3.0-cp37-cp37m-manylinux_2_28_aarch64.whl", hash = "sha256:81b4e48da4c69313192d8c8d4311e5d818b8be1afe68ee20f6385d0e96fc9512"}, {file = "lxml-5.3.0-cp37-cp37m-manylinux_2_28_x86_64.whl", hash = "sha256:2bc9fd5ca4729af796f9f59cd8ff160fe06a474da40aca03fcc79655ddee1a8b"}, {file = "lxml-5.3.0-cp37-cp37m-musllinux_1_2_aarch64.whl", hash = "sha256:07da23d7ee08577760f0a71d67a861019103e4812c87e2fab26b039054594cc5"}, {file = "lxml-5.3.0-cp37-cp37m-musllinux_1_2_x86_64.whl", hash = "sha256:ea2e2f6f801696ad7de8aec061044d6c8c0dd4037608c7cab38a9a4d316bfb11"}, {file = "lxml-5.3.0-cp37-cp37m-win32.whl", hash = "sha256:5c54afdcbb0182d06836cc3d1be921e540be3ebdf8b8a51ee3ef987537455f84"}, {file = "lxml-5.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:f2901429da1e645ce548bf9171784c0f74f0718c3f6150ce166be39e4dd66c3e"}, {file = "lxml-5.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c56a1d43b2f9ee4786e4658c7903f05da35b923fb53c11025712562d5cc02753"}, {file = "lxml-5.3.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6ee8c39582d2652dcd516d1b879451500f8db3fe3607ce45d7c5957ab2596040"}, {file = "lxml-5.3.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0fdf3a3059611f7585a78ee10399a15566356116a4288380921a4b598d807a22"}, {file = "lxml-5.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:146173654d79eb1fc97498b4280c1d3e1e5d58c398fa530905c9ea50ea849b22"}, {file = "lxml-5.3.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:0a7056921edbdd7560746f4221dca89bb7a3fe457d3d74267995253f46343f15"}, {file = "lxml-5.3.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:9e4b47ac0f5e749cfc618efdf4726269441014ae1d5583e047b452a32e221920"}, {file = "lxml-5.3.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:f914c03e6a31deb632e2daa881fe198461f4d06e57ac3d0e05bbcab8eae01945"}, {file = "lxml-5.3.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:213261f168c5e1d9b7535a67e68b1f59f92398dd17a56d934550837143f79c42"}, {file = "lxml-5.3.0-cp38-cp38-win32.whl", hash = "sha256:218c1b2e17a710e363855594230f44060e2025b05c80d1f0661258142b2add2e"}, {file = "lxml-5.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:315f9542011b2c4e1d280e4a20ddcca1761993dda3afc7a73b01235f8641e903"}, {file = "lxml-5.3.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:1ffc23010330c2ab67fac02781df60998ca8fe759e8efde6f8b756a20599c5de"}, {file = "lxml-5.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2b3778cb38212f52fac9fe913017deea2fdf4eb1a4f8e4cfc6b009a13a6d3fcc"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4b0c7a688944891086ba192e21c5229dea54382f4836a209ff8d0a660fac06be"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:747a3d3e98e24597981ca0be0fd922aebd471fa99d0043a3842d00cdcad7ad6a"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:86a6b24b19eaebc448dc56b87c4865527855145d851f9fc3891673ff97950540"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b11a5d918a6216e521c715b02749240fb07ae5a1fefd4b7bf12f833bc8b4fe70"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:68b87753c784d6acb8a25b05cb526c3406913c9d988d51f80adecc2b0775d6aa"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:109fa6fede314cc50eed29e6e56c540075e63d922455346f11e4d7a036d2b8cf"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_28_ppc64le.whl", hash = "sha256:02ced472497b8362c8e902ade23e3300479f4f43e45f4105c85ef43b8db85229"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_28_s390x.whl", hash = "sha256:6b038cc86b285e4f9fea2ba5ee76e89f21ed1ea898e287dc277a25884f3a7dfe"}, {file = "lxml-5.3.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:7437237c6a66b7ca341e868cda48be24b8701862757426852c9b3186de1da8a2"}, {file = "lxml-5.3.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:7f41026c1d64043a36fda21d64c5026762d53a77043e73e94b71f0521939cc71"}, {file = "lxml-5.3.0-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:482c2f67761868f0108b1743098640fbb2a28a8e15bf3f47ada9fa59d9fe08c3"}, {file = "lxml-5.3.0-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:1483fd3358963cc5c1c9b122c80606a3a79ee0875bcac0204149fa09d6ff2727"}, {file = "lxml-5.3.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:2dec2d1130a9cda5b904696cec33b2cfb451304ba9081eeda7f90f724097300a"}, {file = "lxml-5.3.0-cp39-cp39-win32.whl", hash = "sha256:a0eabd0a81625049c5df745209dc7fcef6e2aea7793e5f003ba363610aa0a3ff"}, {file = "lxml-5.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:89e043f1d9d341c52bf2af6d02e6adde62e0a46e6755d5eb60dc6e4f0b8aeca2"}, {file = "lxml-5.3.0-pp310-pypy310_pp73-macosx_10_15_x86_64.whl", hash = "sha256:7b1cd427cb0d5f7393c31b7496419da594fe600e6fdc4b105a54f82405e6626c"}, {file = "lxml-5.3.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:51806cfe0279e06ed8500ce19479d757db42a30fd509940b1701be9c86a5ff9a"}, {file = "lxml-5.3.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ee70d08fd60c9565ba8190f41a46a54096afa0eeb8f76bd66f2c25d3b1b83005"}, {file = "lxml-5.3.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:8dc2c0395bea8254d8daebc76dcf8eb3a95ec2a46fa6fae5eaccee366bfe02ce"}, {file = "lxml-5.3.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:6ba0d3dcac281aad8a0e5b14c7ed6f9fa89c8612b47939fc94f80b16e2e9bc83"}, {file = "lxml-5.3.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:6e91cf736959057f7aac7adfc83481e03615a8e8dd5758aa1d95ea69e8931dba"}, {file = "lxml-5.3.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:94d6c3782907b5e40e21cadf94b13b0842ac421192f26b84c45f13f3c9d5dc27"}, {file = "lxml-5.3.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c300306673aa0f3ed5ed9372b21867690a17dba38c68c44b287437c362ce486b"}, {file = "lxml-5.3.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78d9b952e07aed35fe2e1a7ad26e929595412db48535921c5013edc8aa4a35ce"}, {file = "lxml-5.3.0-pp37-pypy37_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:01220dca0d066d1349bd6a1726856a78f7929f3878f7e2ee83c296c69495309e"}, {file = "lxml-5.3.0-pp37-pypy37_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:2d9b8d9177afaef80c53c0a9e30fa252ff3036fb1c6494d427c066a4ce6a282f"}, {file = "lxml-5.3.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:20094fc3f21ea0a8669dc4c61ed7fa8263bd37d97d93b90f28fc613371e7a875"}, {file = "lxml-5.3.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:ace2c2326a319a0bb8a8b0e5b570c764962e95818de9f259ce814ee666603f19"}, {file = "lxml-5.3.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:92e67a0be1639c251d21e35fe74df6bcc40cba445c2cda7c4a967656733249e2"}, {file = "lxml-5.3.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd5350b55f9fecddc51385463a4f67a5da829bc741e38cf689f38ec9023f54ab"}, {file = "lxml-5.3.0-pp38-pypy38_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:4c1fefd7e3d00921c44dc9ca80a775af49698bbfd92ea84498e56acffd4c5469"}, {file = "lxml-5.3.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:71a8dd38fbd2f2319136d4ae855a7078c69c9a38ae06e0c17c73fd70fc6caad8"}, {file = "lxml-5.3.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:97acf1e1fd66ab53dacd2c35b319d7e548380c2e9e8c54525c6e76d21b1ae3b1"}, {file = "lxml-5.3.0-pp39-pypy39_pp73-macosx_10_15_x86_64.whl", hash = "sha256:68934b242c51eb02907c5b81d138cb977b2129a0a75a8f8b60b01cb8586c7b21"}, {file = "lxml-5.3.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b710bc2b8292966b23a6a0121f7a6c51d45d2347edcc75f016ac123b8054d3f2"}, {file = "lxml-5.3.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:18feb4b93302091b1541221196a2155aa296c363fd233814fa11e181adebc52f"}, {file = "lxml-5.3.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:3eb44520c4724c2e1a57c0af33a379eee41792595023f367ba3952a2d96c2aab"}, {file = "lxml-5.3.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:609251a0ca4770e5a8768ff902aa02bf636339c5a93f9349b48eb1f606f7f3e9"}, {file = "lxml-5.3.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:516f491c834eb320d6c843156440fe7fc0d50b33e44387fcec5b02f0bc118a4c"}, {file = "lxml-5.3.0.tar.gz", hash = "sha256:4e109ca30d1edec1ac60cdbe341905dc3b8f55b16855e03a54aaf59e51ec8c6f"}, ] [package.extras] cssselect = ["cssselect (>=0.7)"] html-clean = ["lxml-html-clean"] html5 = ["html5lib"] htmlsoup = ["BeautifulSoup4"] source = ["Cython (>=3.0.11)"] [[package]] name = "lxml-stubs" version = "0.5.1" description = "Type annotations for the lxml package" optional = false python-versions = "*" files = [ {file = "lxml-stubs-0.5.1.tar.gz", hash = "sha256:e0ec2aa1ce92d91278b719091ce4515c12adc1d564359dfaf81efa7d4feab79d"}, {file = "lxml_stubs-0.5.1-py3-none-any.whl", hash = "sha256:1f689e5dbc4b9247cb09ae820c7d34daeb1fdbd1db06123814b856dae7787272"}, ] [package.extras] test = ["coverage[toml] (>=7.2.5)", "mypy (>=1.2.0)", "pytest (>=7.3.0)", "pytest-mypy-plugins (>=1.10.1)"] [[package]] name = "markdown-it-py" version = "3.0.0" description = "Python port of markdown-it. Markdown parsing, done right!" optional = false python-versions = ">=3.8" files = [ {file = "markdown-it-py-3.0.0.tar.gz", hash = "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"}, {file = "markdown_it_py-3.0.0-py3-none-any.whl", hash = "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1"}, ] [package.dependencies] mdurl = ">=0.1,<1.0" [package.extras] benchmarking = ["psutil", "pytest", "pytest-benchmark"] code-style = ["pre-commit (>=3.0,<4.0)"] compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"] linkify = ["linkify-it-py (>=1,<3)"] plugins = ["mdit-py-plugins"] profiling = ["gprof2dot"] rtd = ["jupyter_sphinx", "mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] [[package]] name = "markupsafe" version = "2.1.5" description = "Safely add untrusted strings to HTML/XML markup." optional = false python-versions = ">=3.7" files = [ {file = "MarkupSafe-2.1.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a17a92de5231666cfbe003f0e4b9b3a7ae3afb1ec2845aadc2bacc93ff85febc"}, {file = "MarkupSafe-2.1.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:72b6be590cc35924b02c78ef34b467da4ba07e4e0f0454a2c5907f473fc50ce5"}, {file = "MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e61659ba32cf2cf1481e575d0462554625196a1f2fc06a1c777d3f48e8865d46"}, {file = "MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2174c595a0d73a3080ca3257b40096db99799265e1c27cc5a610743acd86d62f"}, {file = "MarkupSafe-2.1.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ae2ad8ae6ebee9d2d94b17fb62763125f3f374c25618198f40cbb8b525411900"}, {file = "MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:075202fa5b72c86ad32dc7d0b56024ebdbcf2048c0ba09f1cde31bfdd57bcfff"}, {file = "MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:598e3276b64aff0e7b3451b72e94fa3c238d452e7ddcd893c3ab324717456bad"}, {file = "MarkupSafe-2.1.5-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:fce659a462a1be54d2ffcacea5e3ba2d74daa74f30f5f143fe0c58636e355fdd"}, {file = "MarkupSafe-2.1.5-cp310-cp310-win32.whl", hash = "sha256:d9fad5155d72433c921b782e58892377c44bd6252b5af2f67f16b194987338a4"}, {file = "MarkupSafe-2.1.5-cp310-cp310-win_amd64.whl", hash = "sha256:bf50cd79a75d181c9181df03572cdce0fbb75cc353bc350712073108cba98de5"}, {file = "MarkupSafe-2.1.5-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:629ddd2ca402ae6dbedfceeba9c46d5f7b2a61d9749597d4307f943ef198fc1f"}, {file = "MarkupSafe-2.1.5-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5b7b716f97b52c5a14bffdf688f971b2d5ef4029127f1ad7a513973cfd818df2"}, {file = "MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6ec585f69cec0aa07d945b20805be741395e28ac1627333b1c5b0105962ffced"}, {file = "MarkupSafe-2.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b91c037585eba9095565a3556f611e3cbfaa42ca1e865f7b8015fe5c7336d5a5"}, {file = "MarkupSafe-2.1.5-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7502934a33b54030eaf1194c21c692a534196063db72176b0c4028e140f8f32c"}, {file = "MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0e397ac966fdf721b2c528cf028494e86172b4feba51d65f81ffd65c63798f3f"}, {file = "MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:c061bb86a71b42465156a3ee7bd58c8c2ceacdbeb95d05a99893e08b8467359a"}, {file = "MarkupSafe-2.1.5-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3a57fdd7ce31c7ff06cdfbf31dafa96cc533c21e443d57f5b1ecc6cdc668ec7f"}, {file = "MarkupSafe-2.1.5-cp311-cp311-win32.whl", hash = "sha256:397081c1a0bfb5124355710fe79478cdbeb39626492b15d399526ae53422b906"}, {file = "MarkupSafe-2.1.5-cp311-cp311-win_amd64.whl", hash = "sha256:2b7c57a4dfc4f16f7142221afe5ba4e093e09e728ca65c51f5620c9aaeb9a617"}, {file = "MarkupSafe-2.1.5-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:8dec4936e9c3100156f8a2dc89c4b88d5c435175ff03413b443469c7c8c5f4d1"}, {file = "MarkupSafe-2.1.5-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:3c6b973f22eb18a789b1460b4b91bf04ae3f0c4234a0a6aa6b0a92f6f7b951d4"}, {file = "MarkupSafe-2.1.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ac07bad82163452a6884fe8fa0963fb98c2346ba78d779ec06bd7a6262132aee"}, {file = "MarkupSafe-2.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f5dfb42c4604dddc8e4305050aa6deb084540643ed5804d7455b5df8fe16f5e5"}, {file = "MarkupSafe-2.1.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ea3d8a3d18833cf4304cd2fc9cbb1efe188ca9b5efef2bdac7adc20594a0e46b"}, {file = "MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:d050b3361367a06d752db6ead6e7edeb0009be66bc3bae0ee9d97fb326badc2a"}, {file = "MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:bec0a414d016ac1a18862a519e54b2fd0fc8bbfd6890376898a6c0891dd82e9f"}, {file = "MarkupSafe-2.1.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:58c98fee265677f63a4385256a6d7683ab1832f3ddd1e66fe948d5880c21a169"}, {file = "MarkupSafe-2.1.5-cp312-cp312-win32.whl", hash = "sha256:8590b4ae07a35970728874632fed7bd57b26b0102df2d2b233b6d9d82f6c62ad"}, {file = "MarkupSafe-2.1.5-cp312-cp312-win_amd64.whl", hash = "sha256:823b65d8706e32ad2df51ed89496147a42a2a6e01c13cfb6ffb8b1e92bc910bb"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:c8b29db45f8fe46ad280a7294f5c3ec36dbac9491f2d1c17345be8e69cc5928f"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ec6a563cff360b50eed26f13adc43e61bc0c04d94b8be985e6fb24b81f6dcfdf"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a549b9c31bec33820e885335b451286e2969a2d9e24879f83fe904a5ce59d70a"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4f11aa001c540f62c6166c7726f71f7573b52c68c31f014c25cc7901deea0b52"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:7b2e5a267c855eea6b4283940daa6e88a285f5f2a67f2220203786dfa59b37e9"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:2d2d793e36e230fd32babe143b04cec8a8b3eb8a3122d2aceb4a371e6b09b8df"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:ce409136744f6521e39fd8e2a24c53fa18ad67aa5bc7c2cf83645cce5b5c4e50"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-win32.whl", hash = "sha256:4096e9de5c6fdf43fb4f04c26fb114f61ef0bf2e5604b6ee3019d51b69e8c371"}, {file = "MarkupSafe-2.1.5-cp37-cp37m-win_amd64.whl", hash = "sha256:4275d846e41ecefa46e2015117a9f491e57a71ddd59bbead77e904dc02b1bed2"}, {file = "MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:656f7526c69fac7f600bd1f400991cc282b417d17539a1b228617081106feb4a"}, {file = "MarkupSafe-2.1.5-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:97cafb1f3cbcd3fd2b6fbfb99ae11cdb14deea0736fc2b0952ee177f2b813a46"}, {file = "MarkupSafe-2.1.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1f3fbcb7ef1f16e48246f704ab79d79da8a46891e2da03f8783a5b6fa41a9532"}, {file = "MarkupSafe-2.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fa9db3f79de01457b03d4f01b34cf91bc0048eb2c3846ff26f66687c2f6d16ab"}, {file = "MarkupSafe-2.1.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ffee1f21e5ef0d712f9033568f8344d5da8cc2869dbd08d87c84656e6a2d2f68"}, {file = "MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:5dedb4db619ba5a2787a94d877bc8ffc0566f92a01c0ef214865e54ecc9ee5e0"}, {file = "MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:30b600cf0a7ac9234b2638fbc0fb6158ba5bdcdf46aeb631ead21248b9affbc4"}, {file = "MarkupSafe-2.1.5-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:8dd717634f5a044f860435c1d8c16a270ddf0ef8588d4887037c5028b859b0c3"}, {file = "MarkupSafe-2.1.5-cp38-cp38-win32.whl", hash = "sha256:daa4ee5a243f0f20d528d939d06670a298dd39b1ad5f8a72a4275124a7819eff"}, {file = "MarkupSafe-2.1.5-cp38-cp38-win_amd64.whl", hash = "sha256:619bc166c4f2de5caa5a633b8b7326fbe98e0ccbfacabd87268a2b15ff73a029"}, {file = "MarkupSafe-2.1.5-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:7a68b554d356a91cce1236aa7682dc01df0edba8d043fd1ce607c49dd3c1edcf"}, {file = "MarkupSafe-2.1.5-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:db0b55e0f3cc0be60c1f19efdde9a637c32740486004f20d1cff53c3c0ece4d2"}, {file = "MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3e53af139f8579a6d5f7b76549125f0d94d7e630761a2111bc431fd820e163b8"}, {file = "MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:17b950fccb810b3293638215058e432159d2b71005c74371d784862b7e4683f3"}, {file = "MarkupSafe-2.1.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4c31f53cdae6ecfa91a77820e8b151dba54ab528ba65dfd235c80b086d68a465"}, {file = "MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:bff1b4290a66b490a2f4719358c0cdcd9bafb6b8f061e45c7a2460866bf50c2e"}, {file = "MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:bc1667f8b83f48511b94671e0e441401371dfd0f0a795c7daa4a3cd1dde55bea"}, {file = "MarkupSafe-2.1.5-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5049256f536511ee3f7e1b3f87d1d1209d327e818e6ae1365e8653d7e3abb6a6"}, {file = "MarkupSafe-2.1.5-cp39-cp39-win32.whl", hash = "sha256:00e046b6dd71aa03a41079792f8473dc494d564611a8f89bbbd7cb93295ebdcf"}, {file = "MarkupSafe-2.1.5-cp39-cp39-win_amd64.whl", hash = "sha256:fa173ec60341d6bb97a89f5ea19c85c5643c1e7dedebc22f5181eb73573142c5"}, {file = "MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"}, ] [[package]] name = "mdurl" version = "0.1.2" description = "Markdown URL utilities" optional = false python-versions = ">=3.7" files = [ {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, ] [[package]] name = "mypy" version = "1.11.2" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ {file = "mypy-1.11.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d42a6dd818ffce7be66cce644f1dff482f1d97c53ca70908dff0b9ddc120b77a"}, {file = "mypy-1.11.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:801780c56d1cdb896eacd5619a83e427ce436d86a3bdf9112527f24a66618fef"}, {file = "mypy-1.11.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:41ea707d036a5307ac674ea172875f40c9d55c5394f888b168033177fce47383"}, {file = "mypy-1.11.2-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:6e658bd2d20565ea86da7d91331b0eed6d2eee22dc031579e6297f3e12c758c8"}, {file = "mypy-1.11.2-cp310-cp310-win_amd64.whl", hash = "sha256:478db5f5036817fe45adb7332d927daa62417159d49783041338921dcf646fc7"}, {file = "mypy-1.11.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:75746e06d5fa1e91bfd5432448d00d34593b52e7e91a187d981d08d1f33d4385"}, {file = "mypy-1.11.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:a976775ab2256aadc6add633d44f100a2517d2388906ec4f13231fafbb0eccca"}, {file = "mypy-1.11.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:cd953f221ac1379050a8a646585a29574488974f79d8082cedef62744f0a0104"}, {file = "mypy-1.11.2-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:57555a7715c0a34421013144a33d280e73c08df70f3a18a552938587ce9274f4"}, {file = "mypy-1.11.2-cp311-cp311-win_amd64.whl", hash = "sha256:36383a4fcbad95f2657642a07ba22ff797de26277158f1cc7bd234821468b1b6"}, {file = "mypy-1.11.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:e8960dbbbf36906c5c0b7f4fbf2f0c7ffb20f4898e6a879fcf56a41a08b0d318"}, {file = "mypy-1.11.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:06d26c277962f3fb50e13044674aa10553981ae514288cb7d0a738f495550b36"}, {file = "mypy-1.11.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6e7184632d89d677973a14d00ae4d03214c8bc301ceefcdaf5c474866814c987"}, {file = "mypy-1.11.2-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:3a66169b92452f72117e2da3a576087025449018afc2d8e9bfe5ffab865709ca"}, {file = "mypy-1.11.2-cp312-cp312-win_amd64.whl", hash = "sha256:969ea3ef09617aff826885a22ece0ddef69d95852cdad2f60c8bb06bf1f71f70"}, {file = "mypy-1.11.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:37c7fa6121c1cdfcaac97ce3d3b5588e847aa79b580c1e922bb5d5d2902df19b"}, {file = "mypy-1.11.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:4a8a53bc3ffbd161b5b2a4fff2f0f1e23a33b0168f1c0778ec70e1a3d66deb86"}, {file = "mypy-1.11.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2ff93107f01968ed834f4256bc1fc4475e2fecf6c661260066a985b52741ddce"}, {file = "mypy-1.11.2-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:edb91dded4df17eae4537668b23f0ff6baf3707683734b6a818d5b9d0c0c31a1"}, {file = "mypy-1.11.2-cp38-cp38-win_amd64.whl", hash = "sha256:ee23de8530d99b6db0573c4ef4bd8f39a2a6f9b60655bf7a1357e585a3486f2b"}, {file = "mypy-1.11.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:801ca29f43d5acce85f8e999b1e431fb479cb02d0e11deb7d2abb56bdaf24fd6"}, {file = "mypy-1.11.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:af8d155170fcf87a2afb55b35dc1a0ac21df4431e7d96717621962e4b9192e70"}, {file = "mypy-1.11.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f7821776e5c4286b6a13138cc935e2e9b6fde05e081bdebf5cdb2bb97c9df81d"}, {file = "mypy-1.11.2-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:539c570477a96a4e6fb718b8d5c3e0c0eba1f485df13f86d2970c91f0673148d"}, {file = "mypy-1.11.2-cp39-cp39-win_amd64.whl", hash = "sha256:3f14cd3d386ac4d05c5a39a51b84387403dadbd936e17cb35882134d4f8f0d24"}, {file = "mypy-1.11.2-py3-none-any.whl", hash = "sha256:b499bc07dbdcd3de92b0a8b29fdf592c111276f6a12fe29c30f6c417dd546d12"}, {file = "mypy-1.11.2.tar.gz", hash = "sha256:7f9993ad3e0ffdc95c2a14b66dee63729f021968bff8ad911867579c65d13a79"}, ] [package.dependencies] mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} typing-extensions = ">=4.6.0" [package.extras] dmypy = ["psutil (>=4.0)"] install-types = ["pip"] mypyc = ["setuptools (>=50)"] reports = ["lxml"] [[package]] name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." optional = false python-versions = ">=3.5" files = [ {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, ] [[package]] name = "packaging" version = "24.1" description = "Core utilities for Python packages" optional = false python-versions = ">=3.8" files = [ {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, ] [[package]] name = "paramiko" version = "3.4.1" description = "SSH2 protocol library" optional = false python-versions = ">=3.6" files = [ {file = "paramiko-3.4.1-py3-none-any.whl", hash = "sha256:8e49fd2f82f84acf7ffd57c64311aa2b30e575370dc23bdb375b10262f7eac32"}, {file = "paramiko-3.4.1.tar.gz", hash = "sha256:8b15302870af7f6652f2e038975c1d2973f06046cb5d7d65355668b3ecbece0c"}, ] [package.dependencies] bcrypt = ">=3.2" cryptography = ">=3.3" pynacl = ">=1.5" [package.extras] all = ["gssapi (>=1.4.1)", "invoke (>=2.0)", "pyasn1 (>=0.1.7)", "pywin32 (>=2.1.8)"] gssapi = ["gssapi (>=1.4.1)", "pyasn1 (>=0.1.7)", "pywin32 (>=2.1.8)"] invoke = ["invoke (>=2.0)"] [[package]] name = "pathspec" version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." optional = false python-versions = ">=3.8" files = [ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, ] [[package]] name = "platformdirs" version = "4.2.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" files = [ {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, ] [package.extras] docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] type = ["mypy (>=1.8)"] [[package]] name = "pontos" version = "24.3.2" description = "Common utilities and tools maintained by Greenbone Networks" optional = false python-versions = ">=3.9,<4.0" files = [ {file = "pontos-24.3.2-py3-none-any.whl", hash = "sha256:001cd4a295b8a78db2568788c213ecc27ed0c22231c5065f0f5e943df3c98277"}, {file = "pontos-24.3.2.tar.gz", hash = "sha256:78dc9ad1bda130a4c16d1d70e0f93e529132d3e2b4c76673962e5890350eca1c"}, ] [package.dependencies] colorful = ">=0.5.4" httpx = {version = ">=0.23", extras = ["http2"]} lxml = ">=4.9.0" packaging = ">=20.3" python-dateutil = ">=2.8.2" rich = ">=12.4.4" semver = ">=2.13" shtab = ">=1.7.0" tomlkit = ">=0.5.11" [[package]] name = "pycparser" version = "2.22" description = "C parser in Python" optional = false python-versions = ">=3.8" files = [ {file = "pycparser-2.22-py3-none-any.whl", hash = "sha256:c3702b6d3dd8c7abc1afa565d7e63d53a1d0bd86cdc24edd75470f4de499cfcc"}, {file = "pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6"}, ] [[package]] name = "pygments" version = "2.18.0" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.8" files = [ {file = "pygments-2.18.0-py3-none-any.whl", hash = "sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a"}, {file = "pygments-2.18.0.tar.gz", hash = "sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199"}, ] [package.extras] windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pynacl" version = "1.5.0" description = "Python binding to the Networking and Cryptography (NaCl) library" optional = false python-versions = ">=3.6" files = [ {file = "PyNaCl-1.5.0-cp36-abi3-macosx_10_10_universal2.whl", hash = "sha256:401002a4aaa07c9414132aaed7f6836ff98f59277a234704ff66878c2ee4a0d1"}, {file = "PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl", hash = "sha256:52cb72a79269189d4e0dc537556f4740f7f0a9ec41c1322598799b0bdad4ef92"}, {file = "PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a36d4a9dda1f19ce6e03c9a784a2921a4b726b02e1c736600ca9c22029474394"}, {file = "PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl", hash = "sha256:0c84947a22519e013607c9be43706dd42513f9e6ae5d39d3613ca1e142fba44d"}, {file = "PyNaCl-1.5.0-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06b8f6fa7f5de8d5d2f7573fe8c863c051225a27b61e6860fd047b1775807858"}, {file = "PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:a422368fc821589c228f4c49438a368831cb5bbc0eab5ebe1d7fac9dded6567b"}, {file = "PyNaCl-1.5.0-cp36-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:61f642bf2378713e2c2e1de73444a3778e5f0a38be6fee0fe532fe30060282ff"}, {file = "PyNaCl-1.5.0-cp36-abi3-win32.whl", hash = "sha256:e46dae94e34b085175f8abb3b0aaa7da40767865ac82c928eeb9e57e1ea8a543"}, {file = "PyNaCl-1.5.0-cp36-abi3-win_amd64.whl", hash = "sha256:20f42270d27e1b6a29f54032090b972d97f0a1b0948cc52392041ef7831fee93"}, {file = "PyNaCl-1.5.0.tar.gz", hash = "sha256:8ac7448f09ab85811607bdd21ec2464495ac8b7c66d146bf545b0f08fb9220ba"}, ] [package.dependencies] cffi = ">=1.4.1" [package.extras] docs = ["sphinx (>=1.6.5)", "sphinx-rtd-theme"] tests = ["hypothesis (>=3.27.0)", "pytest (>=3.2.1,!=3.3.0)"] [[package]] name = "python-dateutil" version = "2.9.0.post0" description = "Extensions to the standard Python datetime module" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ {file = "python-dateutil-2.9.0.post0.tar.gz", hash = "sha256:37dd54208da7e1cd875388217d5e00ebd4179249f90fb72437e91a35459a0ad3"}, {file = "python_dateutil-2.9.0.post0-py2.py3-none-any.whl", hash = "sha256:a8b2bc7bffae282281c8140a97d3aa9c14da0b136dfe83f850eea9a5f7470427"}, ] [package.dependencies] six = ">=1.5" [[package]] name = "requests" version = "2.32.3" description = "Python HTTP for Humans." optional = false python-versions = ">=3.8" files = [ {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, ] [package.dependencies] certifi = ">=2017.4.17" charset-normalizer = ">=2,<4" idna = ">=2.5,<4" urllib3 = ">=1.21.1,<3" [package.extras] socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "rich" version = "13.7.1" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.7.0" files = [ {file = "rich-13.7.1-py3-none-any.whl", hash = "sha256:4edbae314f59eb482f54e9e30bf00d33350aaa94f4bfcd4e9e3110e64d0d7222"}, {file = "rich-13.7.1.tar.gz", hash = "sha256:9be308cb1fe2f1f57d67ce99e95af38a1e2bc71ad9813b0e247cf7ffbcc3a432"}, ] [package.dependencies] markdown-it-py = ">=2.2.0" pygments = ">=2.13.0,<3.0.0" [package.extras] jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" version = "0.6.2" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ {file = "ruff-0.6.2-py3-none-linux_armv6l.whl", hash = "sha256:5c8cbc6252deb3ea840ad6a20b0f8583caab0c5ef4f9cca21adc5a92b8f79f3c"}, {file = "ruff-0.6.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:17002fe241e76544448a8e1e6118abecbe8cd10cf68fde635dad480dba594570"}, {file = "ruff-0.6.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:3dbeac76ed13456f8158b8f4fe087bf87882e645c8e8b606dd17b0b66c2c1158"}, {file = "ruff-0.6.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:094600ee88cda325988d3f54e3588c46de5c18dae09d683ace278b11f9d4d534"}, {file = "ruff-0.6.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:316d418fe258c036ba05fbf7dfc1f7d3d4096db63431546163b472285668132b"}, {file = "ruff-0.6.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d72b8b3abf8a2d51b7b9944a41307d2f442558ccb3859bbd87e6ae9be1694a5d"}, {file = "ruff-0.6.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:2aed7e243be68487aa8982e91c6e260982d00da3f38955873aecd5a9204b1d66"}, {file = "ruff-0.6.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d371f7fc9cec83497fe7cf5eaf5b76e22a8efce463de5f775a1826197feb9df8"}, {file = "ruff-0.6.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8f310d63af08f583363dfb844ba8f9417b558199c58a5999215082036d795a1"}, {file = "ruff-0.6.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7db6880c53c56addb8638fe444818183385ec85eeada1d48fc5abe045301b2f1"}, {file = "ruff-0.6.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1175d39faadd9a50718f478d23bfc1d4da5743f1ab56af81a2b6caf0a2394f23"}, {file = "ruff-0.6.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5b939f9c86d51635fe486585389f54582f0d65b8238e08c327c1534844b3bb9a"}, {file = "ruff-0.6.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:d0d62ca91219f906caf9b187dea50d17353f15ec9bb15aae4a606cd697b49b4c"}, {file = "ruff-0.6.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7438a7288f9d67ed3c8ce4d059e67f7ed65e9fe3aa2ab6f5b4b3610e57e3cb56"}, {file = "ruff-0.6.2-py3-none-win32.whl", hash = "sha256:279d5f7d86696df5f9549b56b9b6a7f6c72961b619022b5b7999b15db392a4da"}, {file = "ruff-0.6.2-py3-none-win_amd64.whl", hash = "sha256:d9f3469c7dd43cd22eb1c3fc16926fb8258d50cb1b216658a07be95dd117b0f2"}, {file = "ruff-0.6.2-py3-none-win_arm64.whl", hash = "sha256:f28fcd2cd0e02bdf739297516d5643a945cc7caf09bd9bcb4d932540a5ea4fa9"}, {file = "ruff-0.6.2.tar.gz", hash = "sha256:239ee6beb9e91feb8e0ec384204a763f36cb53fb895a1a364618c6abb076b3be"}, ] [[package]] name = "semver" version = "3.0.2" description = "Python helper for Semantic Versioning (https://semver.org)" optional = false python-versions = ">=3.7" files = [ {file = "semver-3.0.2-py3-none-any.whl", hash = "sha256:b1ea4686fe70b981f85359eda33199d60c53964284e0cfb4977d243e37cf4bf4"}, {file = "semver-3.0.2.tar.gz", hash = "sha256:6253adb39c70f6e51afed2fa7152bcd414c411286088fb4b9effb133885ab4cc"}, ] [[package]] name = "shtab" version = "1.7.1" description = "Automagic shell tab completion for Python CLI applications" optional = false python-versions = ">=3.7" files = [ {file = "shtab-1.7.1-py3-none-any.whl", hash = "sha256:32d3d2ff9022d4c77a62492b6ec875527883891e33c6b479ba4d41a51e259983"}, {file = "shtab-1.7.1.tar.gz", hash = "sha256:4e4bcb02eeb82ec45920a5d0add92eac9c9b63b2804c9196c1f1fdc2d039243c"}, ] [package.extras] dev = ["pytest (>=6)", "pytest-cov", "pytest-timeout"] [[package]] name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" files = [ {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, ] [[package]] name = "sniffio" version = "1.3.1" description = "Sniff out which async library your code is running under" optional = false python-versions = ">=3.7" files = [ {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"}, {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, ] [[package]] name = "snowballstemmer" version = "2.2.0" description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." optional = false python-versions = "*" files = [ {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, ] [[package]] name = "soupsieve" version = "2.6" description = "A modern CSS selector implementation for Beautiful Soup." optional = false python-versions = ">=3.8" files = [ {file = "soupsieve-2.6-py3-none-any.whl", hash = "sha256:e72c4ff06e4fb6e4b5a9f0f55fe6e81514581fca1515028625d0f299c602ccc9"}, {file = "soupsieve-2.6.tar.gz", hash = "sha256:e2e68417777af359ec65daac1057404a3c8a5455bb8abc36f1a9866ab1a51abb"}, ] [[package]] name = "sphinx" version = "7.4.7" description = "Python documentation generator" optional = false python-versions = ">=3.9" files = [ {file = "sphinx-7.4.7-py3-none-any.whl", hash = "sha256:c2419e2135d11f1951cd994d6eb18a1835bd8fdd8429f9ca375dc1f3281bd239"}, {file = "sphinx-7.4.7.tar.gz", hash = "sha256:242f92a7ea7e6c5b406fdc2615413890ba9f699114a9c09192d7dfead2ee9cfe"}, ] [package.dependencies] alabaster = ">=0.7.14,<0.8.0" babel = ">=2.13" colorama = {version = ">=0.4.6", markers = "sys_platform == \"win32\""} docutils = ">=0.20,<0.22" imagesize = ">=1.3" importlib-metadata = {version = ">=6.0", markers = "python_version < \"3.10\""} Jinja2 = ">=3.1" packaging = ">=23.0" Pygments = ">=2.17" requests = ">=2.30.0" snowballstemmer = ">=2.2" sphinxcontrib-applehelp = "*" sphinxcontrib-devhelp = "*" sphinxcontrib-htmlhelp = ">=2.0.0" sphinxcontrib-jsmath = "*" sphinxcontrib-qthelp = "*" sphinxcontrib-serializinghtml = ">=1.1.9" tomli = {version = ">=2", markers = "python_version < \"3.11\""} [package.extras] docs = ["sphinxcontrib-websupport"] lint = ["flake8 (>=6.0)", "importlib-metadata (>=6.0)", "mypy (==1.10.1)", "pytest (>=6.0)", "ruff (==0.5.2)", "sphinx-lint (>=0.9)", "tomli (>=2)", "types-docutils (==0.21.0.20240711)", "types-requests (>=2.30.0)"] test = ["cython (>=3.0)", "defusedxml (>=0.7.1)", "pytest (>=8.0)", "setuptools (>=70.0)", "typing_extensions (>=4.9)"] [[package]] name = "sphinx-basic-ng" version = "1.0.0b2" description = "A modern skeleton for Sphinx themes." optional = false python-versions = ">=3.7" files = [ {file = "sphinx_basic_ng-1.0.0b2-py3-none-any.whl", hash = "sha256:eb09aedbabfb650607e9b4b68c9d240b90b1e1be221d6ad71d61c52e29f7932b"}, {file = "sphinx_basic_ng-1.0.0b2.tar.gz", hash = "sha256:9ec55a47c90c8c002b5960c57492ec3021f5193cb26cebc2dc4ea226848651c9"}, ] [package.dependencies] sphinx = ">=4.0" [package.extras] docs = ["furo", "ipython", "myst-parser", "sphinx-copybutton", "sphinx-inline-tabs"] [[package]] name = "sphinxcontrib-applehelp" version = "2.0.0" description = "sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books" optional = false python-versions = ">=3.9" files = [ {file = "sphinxcontrib_applehelp-2.0.0-py3-none-any.whl", hash = "sha256:4cd3f0ec4ac5dd9c17ec65e9ab272c9b867ea77425228e68ecf08d6b28ddbdb5"}, {file = "sphinxcontrib_applehelp-2.0.0.tar.gz", hash = "sha256:2f29ef331735ce958efa4734873f084941970894c6090408b079c61b2e1c06d1"}, ] [package.extras] lint = ["mypy", "ruff (==0.5.5)", "types-docutils"] standalone = ["Sphinx (>=5)"] test = ["pytest"] [[package]] name = "sphinxcontrib-devhelp" version = "2.0.0" description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp documents" optional = false python-versions = ">=3.9" files = [ {file = "sphinxcontrib_devhelp-2.0.0-py3-none-any.whl", hash = "sha256:aefb8b83854e4b0998877524d1029fd3e6879210422ee3780459e28a1f03a8a2"}, {file = "sphinxcontrib_devhelp-2.0.0.tar.gz", hash = "sha256:411f5d96d445d1d73bb5d52133377b4248ec79db5c793ce7dbe59e074b4dd1ad"}, ] [package.extras] lint = ["mypy", "ruff (==0.5.5)", "types-docutils"] standalone = ["Sphinx (>=5)"] test = ["pytest"] [[package]] name = "sphinxcontrib-htmlhelp" version = "2.1.0" description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" optional = false python-versions = ">=3.9" files = [ {file = "sphinxcontrib_htmlhelp-2.1.0-py3-none-any.whl", hash = "sha256:166759820b47002d22914d64a075ce08f4c46818e17cfc9470a9786b759b19f8"}, {file = "sphinxcontrib_htmlhelp-2.1.0.tar.gz", hash = "sha256:c9e2916ace8aad64cc13a0d233ee22317f2b9025b9cf3295249fa985cc7082e9"}, ] [package.extras] lint = ["mypy", "ruff (==0.5.5)", "types-docutils"] standalone = ["Sphinx (>=5)"] test = ["html5lib", "pytest"] [[package]] name = "sphinxcontrib-jsmath" version = "1.0.1" description = "A sphinx extension which renders display math in HTML via JavaScript" optional = false python-versions = ">=3.5" files = [ {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"}, ] [package.extras] test = ["flake8", "mypy", "pytest"] [[package]] name = "sphinxcontrib-qthelp" version = "2.0.0" description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp documents" optional = false python-versions = ">=3.9" files = [ {file = "sphinxcontrib_qthelp-2.0.0-py3-none-any.whl", hash = "sha256:b18a828cdba941ccd6ee8445dbe72ffa3ef8cbe7505d8cd1fa0d42d3f2d5f3eb"}, {file = "sphinxcontrib_qthelp-2.0.0.tar.gz", hash = "sha256:4fe7d0ac8fc171045be623aba3e2a8f613f8682731f9153bb2e40ece16b9bbab"}, ] [package.extras] lint = ["mypy", "ruff (==0.5.5)", "types-docutils"] standalone = ["Sphinx (>=5)"] test = ["defusedxml (>=0.7.1)", "pytest"] [[package]] name = "sphinxcontrib-serializinghtml" version = "2.0.0" description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)" optional = false python-versions = ">=3.9" files = [ {file = "sphinxcontrib_serializinghtml-2.0.0-py3-none-any.whl", hash = "sha256:6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331"}, {file = "sphinxcontrib_serializinghtml-2.0.0.tar.gz", hash = "sha256:e9d912827f872c029017a53f0ef2180b327c3f7fd23c87229f7a8e8b70031d4d"}, ] [package.extras] lint = ["mypy", "ruff (==0.5.5)", "types-docutils"] standalone = ["Sphinx (>=5)"] test = ["pytest"] [[package]] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" optional = false python-versions = ">=3.7" files = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] [[package]] name = "tomlkit" version = "0.13.2" description = "Style preserving TOML library" optional = false python-versions = ">=3.8" files = [ {file = "tomlkit-0.13.2-py3-none-any.whl", hash = "sha256:7a974427f6e119197f670fbbbeae7bef749a6c14e793db934baefc1b5f03efde"}, {file = "tomlkit-0.13.2.tar.gz", hash = "sha256:fff5fe59a87295b278abd31bec92c15d9bc4a06885ab12bcea52c71119392e79"}, ] [[package]] name = "types-paramiko" version = "3.4.0.20240423" description = "Typing stubs for paramiko" optional = false python-versions = ">=3.8" files = [ {file = "types-paramiko-3.4.0.20240423.tar.gz", hash = "sha256:aaa98dda232c47886563d66743d3a8b66c432790c596bc3bdd3f17f91be2a8c1"}, {file = "types_paramiko-3.4.0.20240423-py3-none-any.whl", hash = "sha256:c56e0d43399a1b909901b1e0375e0ff6ee62e16cd6e00695024abc2e9fe02035"}, ] [package.dependencies] cryptography = ">=37.0.0" [[package]] name = "typing-extensions" version = "4.12.2" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ {file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"}, {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, ] [[package]] name = "urllib3" version = "2.2.2" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" files = [ {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, ] [package.extras] brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] zstd = ["zstandard (>=0.18.0)"] [[package]] name = "zipp" version = "3.20.0" description = "Backport of pathlib-compatible object wrapper for zip files" optional = false python-versions = ">=3.8" files = [ {file = "zipp-3.20.0-py3-none-any.whl", hash = "sha256:58da6168be89f0be59beb194da1250516fdaa062ccebd30127ac65d30045e10d"}, {file = "zipp-3.20.0.tar.gz", hash = "sha256:0145e43d89664cfe1a2e533adc75adafed82fe2da404b4bbb6b026c0157bdb31"}, ] [package.extras] doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] test = ["big-O", "importlib-resources", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] [metadata] lock-version = "2.0" python-versions = "^3.9" content-hash = "ab8577ef4c37473bc1c77282d52f779c8a049283eaf2236b97acac81e3c27581" python-gvm-24.8.0/pyproject.toml000066400000000000000000000041711466406635600166540ustar00rootroot00000000000000[build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry] name = "python-gvm" version = "24.8.0" description = "Library to communicate with remote servers over GMP or OSP" license = "GPL-3.0-or-later" authors = ["Greenbone AG "] readme = "README.md" homepage = "https://github.com/greenbone/python-gvm/" repository = "https://github.com/greenbone/python-gvm/" documentation = "https://greenbone.github.io/python-gvm/" 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.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Operating System :: OS Independent", "Topic :: Software Development :: Libraries :: Python Modules", ] packages = [{ include = "gvm" }, { include = "tests", format = "sdist" }] [tool.poetry.dependencies] python = "^3.9" paramiko = ">=2.7.1" lxml = ">=4.5.0" [tool.poetry.group.dev.dependencies] coverage = ">=7.2" sphinx = ">=5.3.0" autohooks-plugin-ruff = ">=24.1.0" autohooks-plugin-black = ">=22.7.0" autohooks-plugin-mypy = ">=22.7.0" black = ">=22.6.0" pontos = ">=22.7.2" furo = ">=2022.6.21" lxml-stubs = "^0.5.1" types-paramiko = "^3.4.0.20240205" [tool.black] line-length = 80 target-version = ['py39', 'py310', 'py311', 'py312'] exclude = ''' /( \.git | \.venv | \.github | \.vscode | _build | build | dist | docs )/ ''' [tool.ruff] line-length = 80 target-version = "py311" [tool.ruff.lint] extend-select = ["I", "PLE", "PLW"] [tool.autohooks] mode = "poetry" pre-commit = ['autohooks.plugins.black', "autohooks.plugins.ruff"] [tool.coverage.run] branch = true omit = ["tests/*", "*/__init__.py"] source = ["gvm"] [tool.pontos.version] version-module-file = "gvm/__version__.py" [tool.mypy] files = "gvm" ignore_missing_imports = true explicit_package_bases = true allow_redefinition = true python-gvm-24.8.0/tests/000077500000000000000000000000001466406635600150775ustar00rootroot00000000000000python-gvm-24.8.0/tests/__init__.py000066400000000000000000000025651466406635600172200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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-24.8.0/tests/connections/000077500000000000000000000000001466406635600174215ustar00rootroot00000000000000python-gvm-24.8.0/tests/connections/__init__.py000066400000000000000000000001411466406635600215260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/connections/test_debug_connection.py000066400000000000000000000010251466406635600243350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.connections import DebugConnection, GvmConnection from gvm.connections._connection import AbstractGvmConnection class TestConnection(AbstractGvmConnection): def connect(self) -> None: pass class DebugConnectionTestCase(unittest.TestCase): def test_is_gvm_connection(self): connection = DebugConnection(TestConnection()) self.assertTrue(isinstance(connection, GvmConnection)) python-gvm-24.8.0/tests/connections/test_gvm_connection.py000066400000000000000000000033511466406635600240440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from unittest.mock import MagicMock from gvm.connections import ( DEFAULT_TIMEOUT, GvmConnection, ) from gvm.connections._connection import AbstractGvmConnection from gvm.errors import GvmError class TestConnection(AbstractGvmConnection): def connect(self) -> None: pass class GvmConnectionTestCase(unittest.TestCase): # pylint: disable=protected-access def test_init_no_args(self): connection = TestConnection() self.assertIsNone(connection._socket) self.assertEqual(connection._timeout, DEFAULT_TIMEOUT) def test_init_with_none(self): connection = TestConnection(timeout=None) self.assertIsNone(connection._socket) self.assertEqual(connection._timeout, DEFAULT_TIMEOUT) def test_read_no_data(self): read_mock = MagicMock() read_mock.return_value = None connection = TestConnection() connection._read = read_mock with self.assertRaises(GvmError, msg="Remote closed the connection"): connection.read() def test_read_trigger_timeout(self): # mocking the response into two parts, so we run into the timeout # check in the loop read_mock = MagicMock() read_mock.side_effect = [b"xyz", b""] connection = TestConnection(timeout=0) connection._read = read_mock with self.assertRaises( GvmError, msg="Timeout while reading the response" ): connection.read() def test_is_gvm_connection(self): connection = TestConnection() self.assertTrue(isinstance(connection, GvmConnection)) python-gvm-24.8.0/tests/connections/test_ssh_connection.py000066400000000000000000000445331466406635600240570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from io import StringIO from pathlib import Path from unittest.mock import MagicMock, Mock, patch import paramiko from gvm.connections import ( DEFAULT_HOSTNAME, DEFAULT_KNOWN_HOSTS_FILE, DEFAULT_SSH_PASSWORD, DEFAULT_SSH_PORT, DEFAULT_SSH_USERNAME, GvmConnection, SSHConnection, ) from gvm.errors import GvmError class AbortException(Exception): """Just for testing purposes""" class SSHConnectionTestCase(unittest.TestCase): # pylint: disable=protected-access, invalid-name def setUp(self): self.known_hosts_file = Path("known_hosts") self.known_hosts_file.write_text( "127.0.0.1 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBOZWi" "fs+DoMqIa5Nr0wiVrzQNpMbUwaLzuSTN6rNrYA\n", encoding="utf-8", ) def tearDown(self): self.known_hosts_file.unlink(missing_ok=True) 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: SSHConnection ): 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): ssh_connection = SSHConnection(known_hosts_file=self.known_hosts_file) with self.assertRaises(GvmError, msg="SSH Connection failed"): ssh_connection.connect() def test_connect_error_auto_accept_host(self): ssh_connection = SSHConnection( known_hosts_file=self.known_hosts_file, auto_accept_host=True ) 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_auto_accept_host(self): with patch("paramiko.SSHClient", autospec=True) 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, auto_accept_host=True ) 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, timeout=1.0, ) 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() def test_connect_denied_known_hosts_file(self): self.known_hosts_file.chmod(0000) 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() def test_connect_no_known_hosts_file(self): self.known_hosts_file.unlink(missing_ok=True) ssh_connection = SSHConnection( hostname="0.0.0.1", known_hosts_file=self.known_hosts_file, timeout=1.0, ) 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.print") def test_connect_adding_and_save_hostkey(self, _print_mock): input_mock = MagicMock(spec=input) 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, input=input_mock, ) 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=str(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.ssh: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.print") def test_connect_adding_and_dont_save_hostkey(self, _print_mock): input_mock = MagicMock(spec=input) 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, input=input_mock, ) 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=str(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.ssh: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", ) def test_connect_wrong_input(self): input_mock = MagicMock(spec=input) stdout_mock = StringIO() 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, input=input_mock, file=stdout_mock, ) with self.assertLogs("gvm.connections", level="INFO") as cm: hostkeys = paramiko.HostKeys(filename=str(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.ssh: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': ", ) def test_user_denies_auth(self): input_mock = MagicMock(spec=input) stdout_mock = StringIO() exit_mock = MagicMock(side_effect=AbortException("Exit called")) 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, input=input_mock, exit=exit_mock, file=stdout_mock, ) hostkeys = paramiko.HostKeys(filename=str(self.known_hosts_file)) with self.assertRaisesRegex(AbortException, "^Exit called"): ssh_connection._ssh_authentication_input_loop( hostkeys=hostkeys, key=key, ) exit_mock.assert_called_once_with( "User denied key. Host key verification failed." ) 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) 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() ssh_connection.send("blah") 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() ssh_connection.send("blah") 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() def test_is_gvm_connection(self): ssh_connection = SSHConnection(known_hosts_file=self.known_hosts_file) self.assertTrue(isinstance(ssh_connection, GvmConnection)) python-gvm-24.8.0/tests/connections/test_tls_connection.py000066400000000000000000000042441466406635600240570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from unittest.mock import Mock, patch from gvm.connections import ( DEFAULT_GVM_PORT, DEFAULT_HOSTNAME, DEFAULT_TIMEOUT, GvmConnection, TLSConnection, ) class TLSConnectionTestCase(unittest.TestCase): 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) def test_is_gvm_connection(self): connection = TLSConnection() self.assertTrue(isinstance(connection, GvmConnection)) python-gvm-24.8.0/tests/connections/test_unix_socket_connection.py000066400000000000000000000074601466406635600256130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import socketserver import tempfile import threading import unittest import uuid from pathlib import Path from unittest.mock import patch from gvm.connections import ( DEFAULT_TIMEOUT, DEFAULT_UNIX_SOCKET_PATH, GvmConnection, UnixSocketConnection, ) from gvm.errors import GvmError class DummyRequestHandler(socketserver.BaseRequestHandler): def handle(self): response = b'' 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.socket_name = f"{tempfile.gettempdir()}/{str(uuid.uuid4())}.sock" self.socket_path = Path(self.socket_name) self.socket_server = ThreadedUnixStreamServer( self.socket_name, DummyRequestHandler ) self.server_thread = threading.Thread( target=self.socket_server.serve_forever ) self.server_thread.daemon = True self.server_thread.start() def tearDown(self): self.socket_server.server_close() self.socket_server.shutdown() self.server_thread.join(60.0) self.socket_path.unlink(missing_ok=True) def test_unix_socket_connection_connect_read(self): connection = UnixSocketConnection( path=self.socket_name, timeout=DEFAULT_TIMEOUT ) connection.connect() resp = connection.read() self.assertEqual(resp, b'') connection.disconnect() def test_unix_socket_connection_connect_send_bytes_read(self): connection = UnixSocketConnection( path=self.socket_name, timeout=DEFAULT_TIMEOUT ) connection.connect() connection.send(b"") resp = connection.read() self.assertEqual(resp, b'') 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.socket_name, 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.socket_name}" ): connection.connect() connection.disconnect() def test_unix_socket_send_unconnected_socket(self): connection = UnixSocketConnection( path=self.socket_name, 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) def test_is_gvm_connection(self): connection = UnixSocketConnection() self.assertTrue(isinstance(connection, GvmConnection)) python-gvm-24.8.0/tests/protocols/000077500000000000000000000000001466406635600171235ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/__init__.py000066400000000000000000000014451466406635600212400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from typing import Any, Type from gvm.protocols._protocol import GvmProtocol 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(b'') self.finish_send = CallableMock("finish_send") class GmpTestCase(unittest.TestCase): gmp_class: Type[GvmProtocol[Any]] def setUp(self): self.connection = MockConnection() # pylint: disable=not-callable self.gmp = self.gmp_class(self.connection) python-gvm-24.8.0/tests/protocols/core/000077500000000000000000000000001466406635600200535ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/core/__init__.py000066400000000000000000000001321466406635600221600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later python-gvm-24.8.0/tests/protocols/core/test_connection.py000066400000000000000000000102051466406635600236210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import GvmError from gvm.protocols.core import Connection, InvalidStateError class RequestMock: def __init__(self, data: bytes) -> None: self._data = data def __bytes__(self) -> bytes: return self._data class ConnectionTestCase(unittest.TestCase): def test_send_request(self) -> None: request = RequestMock(b"") connection = Connection() data = connection.send(request) self.assertEqual(data, b"") def test_receive_data(self) -> None: request = RequestMock(b"") connection = Connection() connection.send(request) response = connection.receive_data(b"') self.assertIsNotNone(response) self.assertTrue(response.is_success) # type: ignore another_request = RequestMock(b"") connection.send(another_request) response = connection.receive_data(b"') self.assertIsNotNone(response) self.assertTrue(response.is_success) # type: ignore def test_receive_invalid_data(self) -> None: request = RequestMock(b"") connection = Connection() connection.send(request) with self.assertRaisesRegex( GvmError, "^Cannot parse XML response. Response data read b''$", ): connection.receive_data(b"") def test_error_state_close(self) -> None: request = RequestMock(b"") connection = Connection() connection.send(request) with self.assertRaisesRegex( GvmError, "^Cannot parse XML response. Response data read b''$", ): connection.receive_data(b"") with self.assertRaisesRegex( InvalidStateError, "^The connection is in an error state. Please close the connection.$", ): connection.receive_data(b"") with self.assertRaisesRegex( InvalidStateError, "^The connection is in an error state. Please close the connection.$", ): connection.send(request) connection.close() connection.send(request) def test_send_when_receiving_data(self) -> None: request = RequestMock(b"") connection = Connection() connection.send(request) connection.receive_data(b" None: request = RequestMock(b"") connection = Connection() connection.close() data = connection.send(request) self.assertEqual(data, b"") def test_close_after_send(self) -> None: request = RequestMock(b"") connection = Connection() data = connection.send(request) self.assertEqual(data, b"") connection.close() with self.assertRaisesRegex( InvalidStateError, "^Invalid State$", ): connection.receive_data(b"") def test_close_after_receive_data(self) -> None: request = RequestMock(b"") connection = Connection() data = connection.send(request) self.assertEqual(data, b"") connection.receive_data(b"') data = connection.send(request) self.assertEqual(data, b"") python-gvm-24.8.0/tests/protocols/core/test_request.py000066400000000000000000000011371466406635600231560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.protocols.core import Request class RequestMock: def __init__(self, data: bytes) -> None: self._data = data def __bytes__(self) -> bytes: return self._data class RequestTestCase(unittest.TestCase): def test_request(self) -> None: # request is just a protocol and can be implemented by several classes request = RequestMock(b"some data") self.assertIsInstance(request, Request) self.assertEqual(bytes(request), b"some data") python-gvm-24.8.0/tests/protocols/core/test_response.py000066400000000000000000000070041466406635600233230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.protocols.core import Response, StatusError from gvm.xml import Element, XmlError class RequestMock: def __init__(self, data: bytes) -> None: self._data = data def __bytes__(self) -> bytes: return self._data class ResponseTestCase(unittest.TestCase): def test_data(self) -> None: request = RequestMock(b"") response = Response(data=b"", request=request) self.assertEqual(response.data, b"") def test_bytes(self) -> None: request = RequestMock(b"") response = Response(data=b"", request=request) self.assertEqual(bytes(response), b"") def test_request(self) -> None: request = RequestMock(b"") response = Response(data=b"", request=request) self.assertEqual(response.request, request) def test_status_code(self): request = RequestMock(b"") response = Response(data=b"", request=request) self.assertIsNone(response.status_code) response = Response(data=b'', request=request) self.assertIsNone(response.status_code) response = Response(data=b'', request=request) self.assertEqual(response.status_code, 123) def test_is_success(self): request = RequestMock(b"") response = Response(data=b"", request=request) self.assertFalse(response.is_success) response = Response(data=b'', request=request) self.assertFalse(response.is_success) response = Response(data=b'', request=request) self.assertFalse(response.is_success) response = Response(data=b'', request=request) self.assertTrue(response.is_success) def test_raise_for_status(self): request = RequestMock(b"") response = Response(data=b"", request=request) with self.assertRaisesRegex(StatusError, "^Invalid status code None$"): response.raise_for_status() response = Response(data=b'', request=request) with self.assertRaisesRegex(StatusError, "^Invalid status code None$"): response.raise_for_status() response = Response(data=b'', request=request) with self.assertRaisesRegex(StatusError, "^Invalid status code 123$"): response.raise_for_status() response = Response(data=b'', request=request) self.assertIs(response.raise_for_status(), response) def test_xml(self): request = RequestMock(b"") response = Response( data=b'', request=request ) xml = response.xml() self.assertIsInstance(xml, Element) self.assertEqual(xml.tag, "response") sub_element = xml[0] self.assertEqual(sub_element.tag, "some") self.assertEqual(sub_element.attrib["data"], "lorem") def test_invalid_xml(self): request = RequestMock(b"") response = Response(data=b"", request=request) with self.assertRaisesRegex( XmlError, "^Invalid XML b''. Error was .*$" ): response.xml() python-gvm-24.8.0/tests/protocols/core/test_states.py000066400000000000000000000116501466406635600227720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from unittest.mock import MagicMock from gvm.protocols.core import InvalidStateError, Response from gvm.protocols.core._connection import ( AwaitingResponseState, Context, ErrorState, InitialState, ReceivingDataState, ) class RequestMock: def __init__(self, data: bytes) -> None: self._data = data def __bytes__(self) -> bytes: return self._data class InitialStateTestCase(unittest.TestCase): def test_receive_data(self) -> None: context = MagicMock(spec=Context) state = InitialState() state.__set_context__(context) with self.assertRaisesRegex(InvalidStateError, "Invalid State"): state.receive_data(b"some data") def test_close(self) -> None: context = MagicMock(spec=Context) state = InitialState() state.__set_context__(context) state.close() context.__set_state__.assert_not_called() def test_send(self) -> None: context = MagicMock(spec=Context) state = InitialState() state.__set_context__(context) request = RequestMock(b"some data") data = state.send(request) self.assertEqual(data, b"some data") self.assertIsInstance( context.__set_state__.call_args[0][0], AwaitingResponseState ) class AwaitingResponseStateTestCase(unittest.TestCase): def test_receive_data(self) -> None: context = MagicMock(spec=Context) request = RequestMock(b"") state = AwaitingResponseState(request) state.__set_context__(context) response = state.receive_data(b"") self.assertIsNone(response) self.assertIsInstance( context.__set_state__.call_args[0][0], ReceivingDataState ) def test_close(self) -> None: context = MagicMock(spec=Context) request = RequestMock(b"") state = AwaitingResponseState(request) state.__set_context__(context) state.close() self.assertIsInstance( context.__set_state__.call_args[0][0], InitialState ) def test_send(self) -> None: context = MagicMock(spec=Context) request = RequestMock(b"") state = AwaitingResponseState(request) state.__set_context__(context) with self.assertRaisesRegex(InvalidStateError, "Invalid State"): another_request = RequestMock(b"") state.send(another_request) class ErrorStateTestCase(unittest.TestCase): def test_receive_data(self) -> None: context = MagicMock(spec=Context) state = ErrorState() state.__set_context__(context) with self.assertRaisesRegex( InvalidStateError, "^The connection is in an error state. Please close the connection.$", ): state.receive_data(b"some data") def test_close(self) -> None: context = MagicMock(spec=Context) state = ErrorState() state.__set_context__(context) state.close() self.assertIsInstance( context.__set_state__.call_args[0][0], InitialState ) def test_send(self) -> None: context = MagicMock(spec=Context) state = ErrorState() state.__set_context__(context) with self.assertRaisesRegex( InvalidStateError, "^The connection is in an error state. Please close the connection.$", ): state.receive_data(b"some data") class ReceivingDataStateTestCase(unittest.TestCase): def test_receive_data(self) -> None: context = MagicMock(spec=Context) request = RequestMock(b"") state = ReceivingDataState(request) state.__set_context__(context) response = state.receive_data(b"") self.assertIsNone(response) response = state.receive_data(b"") self.assertIsNotNone(response) self.assertIsInstance(response, Response) self.assertEqual(response.data, b"") # type: ignore self.assertIsInstance( context.__set_state__.call_args[0][0], InitialState ) def test_close(self) -> None: context = MagicMock(spec=Context) request = RequestMock(b"") state = ReceivingDataState(request) state.__set_context__(context) state.close() self.assertIsInstance( context.__set_state__.call_args[0][0], InitialState ) def test_send(self) -> None: context = MagicMock(spec=Context) request = RequestMock(b"") state = ReceivingDataState(request) state.__set_context__(context) with self.assertRaisesRegex(InvalidStateError, "Invalid State"): another_request = RequestMock(b"") state.send(another_request) python-gvm-24.8.0/tests/protocols/core/test_xml_reader.py000066400000000000000000000005661466406635600236150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.protocols.core._connection import XmlReader class XmlReaderTestCase(unittest.TestCase): def test_is_end_xml_false(self): reader = XmlReader() reader.start_xml() false = reader.is_end_xml() self.assertFalse(false) python-gvm-24.8.0/tests/protocols/gmp/000077500000000000000000000000001466406635600177065ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmp/__init__.py000066400000000000000000000001411466406635600220130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/protocols/gmp/requests/000077500000000000000000000000001466406635600215615ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmp/requests/__init__.py000066400000000000000000000001321466406635600236660ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later python-gvm-24.8.0/tests/protocols/gmp/requests/test_version.py000066400000000000000000000006471466406635600246660ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.protocols.core import Request from gvm.protocols.gmp.requests import Version class VersionTestCase(unittest.TestCase): def test_version(self) -> None: request = Version.get_version() self.assertIsInstance(request, Request) self.assertEqual(bytes(request), b"") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/000077500000000000000000000000001466406635600222565ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmp/requests/v224/__init__.py000066400000000000000000000001321466406635600243630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_aggregates.py000066400000000000000000000263411466406635600260060ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.protocols.core import Request from gvm.protocols.gmp.requests.v224 import ( Aggregates, AggregateStatistic, EntityType, SortOrder, ) class AggregatesTestCase(unittest.TestCase): def test_get_aggregates(self): """ Test basic get_aggregates calls with only resource_type except special cases for audit, policy, scan_config and task. """ request = Aggregates.get_aggregates(EntityType.ALERT) self.assertIsInstance(request, Request) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates( resource_type=EntityType.CERT_BUND_ADV ) self.assertEqual( bytes(request), b'' ) request = Aggregates.get_aggregates(EntityType.CPE) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.CVE) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.DFN_CERT_ADV) self.assertEqual( bytes(request), b'' ) request = Aggregates.get_aggregates(EntityType.HOST) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.NOTE) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.NVT) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.OPERATING_SYSTEM) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.OVALDEF) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.OVERRIDE) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.REPORT) self.assertEqual(bytes(request), b'') request = Aggregates.get_aggregates(EntityType.RESULT) self.assertEqual(bytes(request), b'') 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. """ request = Aggregates.get_aggregates(EntityType.AUDIT) self.assertEqual( bytes(request), b'' ) request = Aggregates.get_aggregates(EntityType.POLICY) self.assertEqual( bytes(request), b'', ) request = Aggregates.get_aggregates(EntityType.SCAN_CONFIG) self.assertEqual( bytes(request), b'' ) request = Aggregates.get_aggregates(EntityType.TASK) self.assertEqual( bytes(request), b'' ) def test_get_aggregates_missing_resource_type(self): """ Test get_aggregates calls with missing resource_type """ with self.assertRaises(RequiredArgument): Aggregates.get_aggregates(resource_type=None) with self.assertRaises(RequiredArgument): Aggregates.get_aggregates(resource_type="") with self.assertRaises(RequiredArgument): Aggregates.get_aggregates("") def test_get_aggregates_invalid_resource_type(self): """ Test get_aggregates calls with invalid resource_type """ with self.assertRaises(InvalidArgument): Aggregates.get_aggregates(resource_type="foo") def test_get_aggregates_sort_criteria(self): """ Test get_aggregates calls with sort_criteria given as strings """ request = Aggregates.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.assertEqual( bytes(request), b'' b'' b'' b'' b"severity" b"", ) def test_get_aggregates_sort_criteria_enum(self): """ Test get_aggregates calls with sort_criteria given as enums """ request = Aggregates.get_aggregates( EntityType.NVT, group_column="family", sort_criteria=[ { "field": "severity", "stat": AggregateStatistic.MEAN, "order": SortOrder.DESCENDING, } ], data_columns=["severity"], ) self.assertEqual( bytes(request), b'' b'' b"severity" b"", ) def test_get_aggregates_invalid_sort_criteria(self): """ Test get_aggregates calls with invalid sort_criteria """ with self.assertRaises(InvalidArgumentType): Aggregates.get_aggregates( resource_type=EntityType.ALERT, sort_criteria="INVALID" ) with self.assertRaises(InvalidArgumentType): Aggregates.get_aggregates( resource_type=EntityType.ALERT, sort_criteria=["INVALID"] ) with self.assertRaisesRegex( InvalidArgument, "^Invalid argument INVALID. Allowed values are COUNT,C_COUNT,C_SUM," "MAX,MEAN,MIN,SUM,TEXT,VALUE.$", ): Aggregates.get_aggregates( resource_type=EntityType.ALERT, sort_criteria=[{"stat": "INVALID"}], ) with self.assertRaises(InvalidArgument): Aggregates.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) """ request = Aggregates.get_aggregates( EntityType.CPE, first_group=20, max_groups=25 ) self.assertEqual( bytes(request), b'', ) def test_get_aggregates_invalid_group_limits(self): """ Test get_aggregates calls with invalid group limits """ with self.assertRaises(InvalidArgumentType): Aggregates.get_aggregates( EntityType.CPE, first_group="INVALID", max_groups=25 ) with self.assertRaises(InvalidArgumentType): Aggregates.get_aggregates( EntityType.CPE, first_group=1, max_groups="INVALID" ) def test_get_aggregates_data_columns(self): """ Test get_aggregates calls with data_columns """ request = Aggregates.get_aggregates( EntityType.CPE, data_columns=["severity", "cves"] ) self.assertEqual( bytes(request), b'' b"severity" b"cves" b"", ) def test_get_aggregates_invalid_data_columns(self): """ Test get_aggregates calls with invalid data_columns """ with self.assertRaises(InvalidArgumentType): Aggregates.get_aggregates( resource_type=EntityType.ALERT, data_columns=123 ) def test_get_aggregates_group_column(self): """ Test get_aggregates calls with group_column """ request = Aggregates.get_aggregates( EntityType.NVT, group_column="family" ) self.assertEqual( bytes(request), b'', ) def test_get_aggregates_subgroup_column(self): """ Test get_aggregates calls with subgroup_column """ request = Aggregates.get_aggregates( EntityType.NVT, group_column="family", subgroup_column="solution_type", ) self.assertEqual( bytes(request), b'', ) 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): Aggregates.get_aggregates( resource_type=EntityType.NVT, subgroup_column="solution_type" ) with self.assertRaises(RequiredArgument): Aggregates.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 """ request = Aggregates.get_aggregates( EntityType.SCAN_CONFIG, group_column="uuid", text_columns=["name", "comment"], ) self.assertEqual( bytes(request), b'' b"name" b"comment" b"", ) def test_get_aggregates_invalid_text_columns(self): """ Test get_aggregates calls with invalid text_columns """ with self.assertRaises(InvalidArgumentType): Aggregates.get_aggregates( resource_type=EntityType.ALERT, text_columns=123 ) def test_get_aggregates_mode(self): """ Test get_aggregates calls with mode """ request = Aggregates.get_aggregates( EntityType.NVT, group_column="name", mode="word_counts" ) self.assertEqual( bytes(request), b'', ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_alerts.py000066400000000000000000000661661466406635600252000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import ( AlertCondition, AlertEvent, AlertMethod, Alerts, ReportFormatType, ) class AlertsTestCase(unittest.TestCase): def test_create_alerts(self): request = Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) self.assertEqual( bytes(request), b"" b"foo" b"Always" b"Task run status changed" b"Email" b"", ) def test_create_alert_with_filter_id(self): request = Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, filter_id="f1", ) self.assertEqual( bytes(request), b"" b"foo" b"Always" b"Task run status changed" b"Email" b'' b"", ) def test_create_alert_with_comment(self): request = Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, comment="bar", ) self.assertEqual( bytes(request), b"" b"foo" b"Always" b"Task run status changed" b"Email" b"bar" b"", ) def test_create_alert_with_condition_data(self): request = Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, condition_data={"foo": "bar"}, ) self.assertEqual( bytes(request), b"" b"foo" b"Alwaysbarfoo" b"Task run status changed" b"Email" b"", ) def test_create_alert_with_event_data(self): request = Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, event_data={"foo": "bar"}, ) self.assertEqual( bytes(request), b"" b"foo" b"Always" b"Task run status changed" b"barfoo" b"" b"Email" b"", ) def test_create_alert_with_method_data(self): request = Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, method_data={"foo": "bar"}, ) self.assertEqual( bytes(request), b"" b"foo" b"Always" b"Task run status changed" b"Emailbarfoo" b"", ) def test_create_alert_missing_name(self): with self.assertRaises(RequiredArgument): Alerts.create_alert( "", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) with self.assertRaises(RequiredArgument): Alerts.create_alert( None, condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) def test_create_alert_missing_event(self): with self.assertRaises(RequiredArgument): Alerts.create_alert( "foo", condition=AlertCondition.ALWAYS, event=None, method=AlertMethod.EMAIL, ) with self.assertRaises(RequiredArgument): Alerts.create_alert( "foo", condition=AlertCondition.ALWAYS, event="", method=AlertMethod.EMAIL, ) def test_create_alert_missing_condition(self): with self.assertRaises(RequiredArgument): Alerts.create_alert( "foo", condition=None, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) with self.assertRaises(RequiredArgument): Alerts.create_alert( "foo", condition="", event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) def test_create_alert_missing_method(self): with self.assertRaises(RequiredArgument): Alerts.create_alert( "foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=None, ) with self.assertRaises(RequiredArgument): Alerts.create_alert( "foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method="", ) def test_create_alert_invalid_condition(self): with self.assertRaises(InvalidArgument): Alerts.create_alert( "foo", condition="foo", event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) def test_create_alert_invalid_event(self): with self.assertRaises(InvalidArgument): Alerts.create_alert( "foo", condition=AlertCondition.ALWAYS, event="foo", method=AlertMethod.EMAIL, ) def test_create_alert_invalid_method(self): with self.assertRaises(InvalidArgument): Alerts.create_alert( "foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method="foo", ) def test_create_alert_invalid_condition_for_secinfo(self): with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.SEVERITY_AT_LEAST, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.EMAIL, ) def test_create_alert_invalid_method_for_secinfo(self): with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.HTTP_GET, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.ALEMBA_VFIRE, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.SOURCEFIRE_CONNECTOR, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.START_TASK, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.TIPPINGPOINT_SMS, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.UPDATED_SECINFO_ARRIVED, method=AlertMethod.VERINICE_CONNECTOR, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.HTTP_GET, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.ALEMBA_VFIRE, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.SOURCEFIRE_CONNECTOR, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.START_TASK, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.TIPPINGPOINT_SMS, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.VERINICE_CONNECTOR, ) def test_create_alert_missing_method_for_ticket_received(self): with self.assertRaises(RequiredArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=None, ) def test_create_alert_missing_condition_for_ticket_received(self): with self.assertRaises(RequiredArgument): Alerts.create_alert( name="foo", condition=None, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.EMAIL, ) def test_create_alert_invalid_method_for_ticket_received(self): with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.HTTP_GET, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SCP, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SEND, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SMB, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SNMP, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.ALEMBA_VFIRE, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.VERINICE_CONNECTOR, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.TIPPINGPOINT_SMS, ) with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ALWAYS, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.SOURCEFIRE_CONNECTOR, ) def test_create_alert_invalid_condition_for_task_run_status_changed(self): with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.ERROR, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, ) def test_create_alert_invalid_condition_for_ticket_received(self): with self.assertRaises(InvalidArgument): Alerts.create_alert( name="foo", condition=AlertCondition.FILTER_COUNT_AT_LEAST, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.EMAIL, ) def test_modify_alert(self): request = Alerts.modify_alert( alert_id="a1", ) self.assertEqual(bytes(request), b'') def test_modify_alert_missing_alert_id(self): with self.assertRaises(RequiredArgument): Alerts.modify_alert(alert_id="") with self.assertRaises(RequiredArgument): Alerts.modify_alert(alert_id=None) def test_modify_alert_with_comment(self): request = Alerts.modify_alert( alert_id="a1", comment="foo", ) self.assertEqual( bytes(request), b'foo', ) def test_modify_alert_with_name(self): request = Alerts.modify_alert( alert_id="a1", name="foo", ) self.assertEqual( bytes(request), b'foo', ) def test_modify_alert_with_filter_id(self): request = Alerts.modify_alert( alert_id="a1", filter_id="f1", ) self.assertEqual( bytes(request), b'', ) def test_modify_alert_with_event_data(self): request = Alerts.modify_alert( alert_id="a1", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, event_data={"foo": "bar"}, ) self.assertEqual( bytes(request), b'' b"Always" b"Email" b"Task run status changed" b"barfoo" b"" b"", ) def test_modify_alert_with_condition_data(self): request = Alerts.modify_alert( alert_id="a1", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, condition_data={"foo": "bar"}, ) self.assertEqual( bytes(request), b'' b"Alwaysbarfoo" b"Email" b"Task run status changed" b"", ) def test_modify_alert_with_method_data(self): request = Alerts.modify_alert( alert_id="a1", condition=AlertCondition.ALWAYS, event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.EMAIL, method_data={"foo": "bar"}, ) self.assertEqual( bytes(request), b'' b"Always" b"Emailbarfoo" b"Task run status changed" b"", ) def test_modify_alert_invalid_condition(self): with self.assertRaises(InvalidArgument): Alerts.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(InvalidArgument): Alerts.modify_alert( alert_id="a1", condition=AlertCondition.ALWAYS, event="lorem", method=AlertMethod.SCP, ) def test_modify_alert_invalid_method(self): with self.assertRaises(InvalidArgument): Alerts.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"): Alerts.modify_alert( alert_id="a1", event=AlertEvent.TASK_RUN_STATUS_CHANGED, condition=AlertCondition.ALWAYS, ) with self.assertRaisesRegex(RequiredArgument, "method is required"): Alerts.modify_alert( alert_id="a1", event=AlertEvent.NEW_SECINFO_ARRIVED, condition=AlertCondition.ALWAYS, ) with self.assertRaisesRegex(RequiredArgument, "method is required"): Alerts.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"): Alerts.modify_alert( alert_id="a1", event=AlertEvent.TASK_RUN_STATUS_CHANGED, method=AlertMethod.SCP, ) with self.assertRaisesRegex(RequiredArgument, "condition is required"): Alerts.modify_alert( alert_id="a1", event=AlertEvent.NEW_SECINFO_ARRIVED, method=AlertMethod.SCP, ) with self.assertRaisesRegex(RequiredArgument, "condition is required"): Alerts.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(InvalidArgument): Alerts.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(InvalidArgument): Alerts.modify_alert( alert_id="a1", condition="Always", event="Updated SecInfo arrived", method="HTTP Get", ) def test_modify_missing_method_for_ticket_received(self): with self.assertRaises(RequiredArgument): Alerts.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): Alerts.modify_alert( alert_id="a1", condition=None, event=AlertEvent.TICKET_RECEIVED, method=AlertMethod.EMAIL, ) def test_clone_alert(self): request = Alerts.clone_alert(alert_id="a1") self.assertEqual( bytes(request), b"a1" ) def test_clone_alert_missing_alert_id(self): with self.assertRaises(RequiredArgument): Alerts.clone_alert(alert_id="") with self.assertRaises(RequiredArgument): Alerts.clone_alert(alert_id=None) def test_delete_alert(self): request = Alerts.delete_alert(alert_id="a1") self.assertEqual( bytes(request), b'' ) def test_delete_alert_ultimate(self): request = Alerts.delete_alert(alert_id="a1", ultimate=True) self.assertEqual( bytes(request), b'' ) request = Alerts.delete_alert(alert_id="a1", ultimate=False) self.assertEqual( bytes(request), b'' ) def test_delete_alert_missing_alert_id(self): with self.assertRaises(RequiredArgument): Alerts.delete_alert(alert_id="") with self.assertRaises(RequiredArgument): Alerts.delete_alert(alert_id=None) def test_test_alert(self): request = Alerts.test_alert(alert_id="a1") self.assertEqual(bytes(request), b'') def test_test_alert_missing_alert_id(self): with self.assertRaises(RequiredArgument): Alerts.test_alert(alert_id="") with self.assertRaises(RequiredArgument): Alerts.test_alert(alert_id=None) def test_trigger_alert(self): request = Alerts.trigger_alert(alert_id="a1", report_id="r1") self.assertEqual( bytes(request), b'' ) def test_trigger_alert_with_filter_string(self): request = Alerts.trigger_alert( alert_id="a1", report_id="r1", filter_string="name=foo" ) self.assertEqual( bytes(request), b'', ) def test_trigger_alert_with_filter_id(self): request = Alerts.trigger_alert( alert_id="a1", report_id="r1", filter_id="f1" ) self.assertEqual( bytes(request), b'', ) def test_trigger_alert_with_report_format_id(self): request = Alerts.trigger_alert( alert_id="a1", report_id="r1", report_format_id="bar" ) self.assertEqual( bytes(request), b'', ) def test_trigger_alert_with_report_format_type(self): request = Alerts.trigger_alert( alert_id="a1", report_id="r1", report_format_id=ReportFormatType.SVG, ) self.assertEqual( bytes(request), ''.encode(encoding="utf-8"), ) def test_trigger_alert_with_delta_report_id(self): request = Alerts.trigger_alert( alert_id="a1", report_id="r1", delta_report_id="d1" ) self.assertEqual( bytes(request), b'', ) def test_trigger_alert_missing_alert_id(self): with self.assertRaises(RequiredArgument): Alerts.trigger_alert(alert_id="", report_id="r1") with self.assertRaises(RequiredArgument): Alerts.trigger_alert(alert_id=None, report_id="r1") def test_trigger_alert_missing_report_id(self): with self.assertRaises(RequiredArgument): Alerts.trigger_alert(alert_id="a1", report_id="") with self.assertRaises(RequiredArgument): Alerts.trigger_alert(alert_id="a1", report_id=None) def test_get_alerts(self): request = Alerts.get_alerts() self.assertEqual(bytes(request), b"") def test_get_alerts_with_trash(self): request = Alerts.get_alerts(trash=True) self.assertEqual(bytes(request), b'') request = Alerts.get_alerts(trash=False) self.assertEqual(bytes(request), b'') def test_get_alerts_with_filter_string(self): request = Alerts.get_alerts(filter_string="foo=bar") self.assertEqual(bytes(request), b'') def test_get_alerts_with_filter_id(self): request = Alerts.get_alerts(filter_id="f1") self.assertEqual(bytes(request), b'') def test_get_alerts_with_tasks(self): request = Alerts.get_alerts(tasks=True) self.assertEqual(bytes(request), b'') request = Alerts.get_alerts(tasks=False) self.assertEqual(bytes(request), b'') def test_get_alert(self): request = Alerts.get_alert(alert_id="a1") self.assertEqual(bytes(request), b'') def test_get_alert_with_tasks(self): request = Alerts.get_alert(alert_id="a1", tasks=True) self.assertEqual( bytes(request), b'' ) request = Alerts.get_alert(alert_id="a1", tasks=False) self.assertEqual( bytes(request), b'' ) def test_get_alert_invalid_alert_id(self): with self.assertRaises(RequiredArgument): Alerts.get_alert(alert_id=None) with self.assertRaises(RequiredArgument): Alerts.get_alert(alert_id="") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_audits.py000066400000000000000000000533331466406635600251670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Audits, HostsOrdering class AuditsTestCase(unittest.TestCase): def test_create_audit(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1" ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"", ) def test_create_audit_with_comment(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", comment="bar", ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"bar" b"", ) def test_create_audit_with_single_alert(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", alert_ids=["a1"], ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b'' b"", ) def test_create_audit_with_multiple_alerts(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", alert_ids=["a1", "a2"], ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b'' b'' b"", ) def test_create_audit_with_empty_alert_ids(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", alert_ids=[], ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"", ) def test_create_audit_with_alterable(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", alterable=True, ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"1" b"", ) request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", alterable=False, ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"0" b"", ) def test_create_audit_with_hosts_ordering(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", hosts_ordering=HostsOrdering.RANDOM, ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"random" b"", ) request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", hosts_ordering="random", ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"random" b"", ) def test_create_audit_with_schedule_id(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", schedule_id="s1", ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b'' b"", ) def test_create_audit_with_schedule_and_schedule_periods(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", schedule_id="s1", schedule_periods=0, ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b'' b"0" b"", ) request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", schedule_id="s1", schedule_periods=5, ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b'' b"5" b"", ) def test_create_audit_with_observers(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", observers=["u1", "u2"], ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"u1,u2" b"", ) def test_create_audit_with_preferences(self): request = Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", preferences={"foo": "bar", "lorem": "ipsum"}, ) self.assertEqual( bytes(request), b"" b"foo" b"audit" b'' b'' b'' b"" b"" b"foo" b"bar" b"" b"" b"lorem" b"ipsum" b"" b"" b"", ) def test_create_audit_don_t_allow_container_task(self): with self.assertRaises(InvalidArgument): Audits.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): Audits.create_audit( name="foo", policy_id="c1", target_id=0, scanner_id="s1", observers="", ) def test_create_audit_missing_name(self): with self.assertRaises(RequiredArgument): Audits.create_audit( "", policy_id="c1", target_id="t1", scanner_id="s1" ) with self.assertRaises(RequiredArgument): Audits.create_audit( None, policy_id="c1", target_id="t1", scanner_id="s1" ) def test_create_audit_missing_policy_id(self): with self.assertRaises(RequiredArgument): Audits.create_audit( "foo", policy_id="", target_id="t1", scanner_id="s1" ) with self.assertRaises(RequiredArgument): Audits.create_audit( "foo", policy_id=None, target_id="t1", scanner_id="s1" ) def test_create_audit_missing_target_id(self): with self.assertRaises(RequiredArgument): Audits.create_audit( "foo", policy_id="c1", target_id="", scanner_id="s1" ) with self.assertRaises(RequiredArgument): Audits.create_audit( "foo", policy_id="c1", target_id=None, scanner_id="s1" ) def test_create_audit_missing_scanner_id(self): with self.assertRaises(RequiredArgument): Audits.create_audit( "foo", policy_id="c1", target_id="t1", scanner_id="" ) with self.assertRaises(RequiredArgument): Audits.create_audit( "foo", policy_id="c1", target_id="t1", scanner_id=None ) def test_create_audit_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgument): Audits.create_audit( "foo", policy_id="c1", target_id="t1", scanner_id="s1", hosts_ordering="invalid", ) def test_create_audit_with_schedule_and_invalid_schedule_periods(self): with self.assertRaises(InvalidArgument): Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", schedule_id="s1", schedule_periods=-1, ) with self.assertRaises(InvalidArgument): Audits.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", schedule_id="s1", schedule_periods="invalid", ) def test_modify_audit(self): request = Audits.modify_audit("t1") self.assertEqual(bytes(request), b'') def test_modify_audit_missing_audit_id(self): with self.assertRaises(RequiredArgument): Audits.modify_audit(None) with self.assertRaises(RequiredArgument): Audits.modify_audit("") def test_modify_audit_with_name(self): request = Audits.modify_audit(audit_id="t1", name="foo") self.assertEqual( bytes(request), b'foo', ) def test_modify_audit_with_policy_id(self): request = Audits.modify_audit(audit_id="t1", policy_id="c1") self.assertEqual( bytes(request), b'', ) def test_modify_audit_with_target_id(self): request = Audits.modify_audit(audit_id="t1", target_id="t1") self.assertEqual( bytes(request), b'', ) def test_modify_audit_with_scanner_id(self): request = Audits.modify_audit(audit_id="t1", scanner_id="s1") self.assertEqual( bytes(request), b'', ) def test_modify_audit_with_schedule_id(self): request = Audits.modify_audit(audit_id="t1", schedule_id="s1") self.assertEqual( bytes(request), b'', ) def test_modify_audit_with_comment(self): request = Audits.modify_audit(audit_id="t1", comment="bar") self.assertEqual( bytes(request), b'' b"bar" b"", ) def test_modify_audit_with_alerts_ids(self): request = Audits.modify_audit(audit_id="t1", alert_ids=["a1", "a2"]) self.assertEqual( bytes(request), b'' b'' b'' b"", ) def test_modify_audit_with_empty_alert_ids(self): request = Audits.modify_audit(audit_id="t1", alert_ids=[]) self.assertEqual( bytes(request), b'', ) def test_modify_audit_with_alterable(self): request = Audits.modify_audit(audit_id="t1", alterable=True) self.assertEqual( bytes(request), b'1', ) request = Audits.modify_audit(audit_id="t1", alterable=False) self.assertEqual( bytes(request), b'0', ) def test_modify_audit_with_hosts_ordering(self): request = Audits.modify_audit( audit_id="t1", hosts_ordering=HostsOrdering.RANDOM ) self.assertEqual( bytes(request), b'' b"random" b"", ) request = Audits.modify_audit(audit_id="t1", hosts_ordering="random") self.assertEqual( bytes(request), b'' b"random" b"", ) def test_modify_audit_with_schedule_periods(self): request = Audits.modify_audit(audit_id="t1", schedule_periods=0) self.assertEqual( bytes(request), b'' b"0" b"", ) request = Audits.modify_audit(audit_id="t1", schedule_periods=5) self.assertEqual( bytes(request), b'' b"5" b"", ) def test_modify_audit_with_observers(self): request = Audits.modify_audit(audit_id="t1", observers=["u1", "u2"]) self.assertEqual( bytes(request), b'' b"u1,u2" b"", ) def test_modify_audit_with_preferences(self): request = Audits.modify_audit( audit_id="t1", preferences={"foo": "bar", "lorem": "ipsum"} ) self.assertEqual( bytes(request), b'' b"" b"" b"foo" b"bar" b"" b"" b"lorem" b"ipsum" b"" b"" b"", ) def test_modify_audit_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgument): Audits.modify_audit(audit_id="t1", hosts_ordering="foo") def test_modify_audit_invalid_schedule_periods(self): with self.assertRaises(InvalidArgument): Audits.modify_audit(audit_id="t1", schedule_periods="foo") with self.assertRaises(InvalidArgument): Audits.modify_audit(audit_id="t1", schedule_periods=-1) def test_clone_audit(self): request = Audits.clone_audit("t1") self.assertEqual( bytes(request), b"t1", ) def test_clone_audit_missing_audit_id(self): with self.assertRaises(RequiredArgument): Audits.clone_audit(None) with self.assertRaises(RequiredArgument): Audits.clone_audit("") def test_delete_audit(self): request = Audits.delete_audit("t1") self.assertEqual( bytes(request), b'', ) def test_delete_audit_with_ultimate(self): request = Audits.delete_audit("t1", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Audits.delete_audit("t1", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_audit_missing_audit_id(self): with self.assertRaises(RequiredArgument): Audits.delete_audit(None) with self.assertRaises(RequiredArgument): Audits.delete_audit("") def test_get_audits(self): request = Audits.get_audits() self.assertEqual(bytes(request), b'') def test_get_audits_with_filter_string(self): request = Audits.get_audits(filter_string="name=foo") self.assertEqual( bytes(request), b'', ) def test_get_audits_with_filter_id(self): request = Audits.get_audits(filter_id="f1") self.assertEqual( bytes(request), b'', ) def test_get_audits_with_trash(self): request = Audits.get_audits(trash=True) self.assertEqual( bytes(request), b'', ) request = Audits.get_audits(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_audits_with_details(self): request = Audits.get_audits(details=True) self.assertEqual( bytes(request), b'', ) request = Audits.get_audits(details=False) self.assertEqual( bytes(request), b'', ) def test_get_audits_with_schedules_only(self): request = Audits.get_audits(schedules_only=True) self.assertEqual( bytes(request), b'', ) request = Audits.get_audits(schedules_only=False) self.assertEqual( bytes(request), b'', ) def test_get_audit(self): request = Audits.get_audit("t1") self.assertEqual( bytes(request), b'', ) def test_get_audit_missing_audit_id(self): with self.assertRaises(RequiredArgument): Audits.get_audit(None) with self.assertRaises(RequiredArgument): Audits.get_audit("") def test_start_audit(self): request = Audits.start_audit("t1") self.assertEqual( bytes(request), b'', ) def test_start_audit_missing_audit_id(self): with self.assertRaises(RequiredArgument): Audits.start_audit(None) with self.assertRaises(RequiredArgument): Audits.start_audit("") def test_stop_audit(self): request = Audits.stop_audit("t1") self.assertEqual( bytes(request), b'', ) def test_stop_audit_missing_audit_id(self): with self.assertRaises(RequiredArgument): Audits.stop_audit(None) with self.assertRaises(RequiredArgument): Audits.stop_audit("") def test_resume_audit(self): request = Audits.resume_audit("t1") self.assertEqual( bytes(request), b'', ) def test_resume_audit_missing_audit_id(self): with self.assertRaises(RequiredArgument): Audits.resume_audit(None) with self.assertRaises(RequiredArgument): Audits.resume_audit("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_auth.py000066400000000000000000000062401466406635600246320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.core import Request from gvm.protocols.gmp.requests.v224 import Authentication class AuthenticationTestCase(unittest.TestCase): def test_authenticate(self) -> None: request = Authentication.authenticate("admin", "admin") self.assertIsInstance(request, Request) self.assertEqual( bytes(request), b"admin" b"admin", ) def test_authenticate_missing_username(self) -> None: with self.assertRaises(RequiredArgument): Authentication.authenticate(None, "foo") # type: ignore with self.assertRaises(RequiredArgument): Authentication.authenticate("", "foo") def test_authenticate_missing_password(self) -> None: with self.assertRaises(RequiredArgument): Authentication.authenticate("bar", None) # type: ignore with self.assertRaises(RequiredArgument): Authentication.authenticate("bar", "") def test_describe_auth(self) -> None: request = Authentication.describe_auth() self.assertIsInstance(request, Request) self.assertEqual(bytes(request), b"") def test_modify_auth(self) -> None: request = Authentication.modify_auth( "foo", dict([("foo", "bar"), ("lorem", "ipsum")]) ) self.assertIsInstance(request, Request) self.assertEqual( bytes(request), b"" b'' b"" b"foo" b"bar" b"" b"" b"lorem" b"ipsum" b"" b"" b"", ) def test_modify_auth_missing_group_name(self) -> None: with self.assertRaises(RequiredArgument): Authentication.modify_auth( group_name=None, auth_conf_settings={"foo": "bar"} # type: ignore ) with self.assertRaises(RequiredArgument): Authentication.modify_auth( group_name="", auth_conf_settings={"foo": "bar"} ) with self.assertRaises(RequiredArgument): Authentication.modify_auth("", auth_conf_settings={"foo": "bar"}) def test_modify_auth_auth_conf_settings(self) -> None: with self.assertRaises(RequiredArgument): Authentication.modify_auth( group_name="foo", auth_conf_settings=None # type: ignore ) with self.assertRaises(RequiredArgument): Authentication.modify_auth(group_name="foo", auth_conf_settings="") # type: ignore with self.assertRaises(RequiredArgument): Authentication.modify_auth("foo", "") # type: ignore with self.assertRaises(RequiredArgument): Authentication.modify_auth("foo", {}) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_cert_bund_advisories.py000066400000000000000000000044711466406635600300720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import CertBundAdvisories class CertBundAdvisoriesTestCase(unittest.TestCase): def test_get_cert_bund_advisories(self): request = CertBundAdvisories.get_cert_bund_advisories() self.assertEqual( bytes(request), b'', ) def test_get_cert_bund_advisories_with_filter_string(self): request = CertBundAdvisories.get_cert_bund_advisories( filter_string="filter_string" ) self.assertEqual( bytes(request), b'', ) def test_get_cert_bund_advisories_with_filter_id(self): request = CertBundAdvisories.get_cert_bund_advisories( filter_id="filter_id" ) self.assertEqual( bytes(request), b'', ) def test_get_cert_bund_advisories_with_name(self): request = CertBundAdvisories.get_cert_bund_advisories(name="name") self.assertEqual( bytes(request), b'', ) def test_get_cert_bund_advisories_with_details(self): request = CertBundAdvisories.get_cert_bund_advisories(details=True) self.assertEqual( bytes(request), b'', ) request = CertBundAdvisories.get_cert_bund_advisories(details=False) self.assertEqual( bytes(request), b'', ) def test_get_cert_bund_advisory(self): request = CertBundAdvisories.get_cert_bund_advisory("cert_id") self.assertEqual( bytes(request), b'', ) def test_get_cert_bund_advisory_missing_cert_id(self): with self.assertRaises(RequiredArgument): CertBundAdvisories.get_cert_bund_advisory(None) with self.assertRaises(RequiredArgument): CertBundAdvisories.get_cert_bund_advisory("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_cpes.py000066400000000000000000000034571466406635600246320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Cpes class CpesTestCase(unittest.TestCase): def test_get_cpes(self): request = Cpes.get_cpes() self.assertEqual( bytes(request), b'', ) def test_get_cpes_with_filter_string(self): request = Cpes.get_cpes(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_cpes_with_filter_id(self): request = Cpes.get_cpes(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_cpes_with_name(self): request = Cpes.get_cpes(name="name") self.assertEqual( bytes(request), b'', ) def test_get_cpes_with_details(self): request = Cpes.get_cpes(details=True) self.assertEqual( bytes(request), b'', ) request = Cpes.get_cpes(details=False) self.assertEqual( bytes(request), b'', ) def test_get_cpe(self): request = Cpes.get_cpe("cpe_id") self.assertEqual( bytes(request), b'', ) def test_get_cpe_missing_cpe_id(self): with self.assertRaises(RequiredArgument): Cpes.get_cpe(None) with self.assertRaises(RequiredArgument): Cpes.get_cpe("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_credentials.py000066400000000000000000000662651466406635600262030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import ( CredentialFormat, Credentials, CredentialType, SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, ) class CredentialsTestCase(unittest.TestCase): def test_clone_credential_missing_credential_id(self): with self.assertRaises(RequiredArgument): Credentials.clone_credential(None) with self.assertRaises(RequiredArgument): Credentials.clone_credential("") def test_clone_credential(self): request = Credentials.clone_credential("a1") self.assertEqual( bytes(request), b"a1", ) def test_create_credential_missing_name(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( None, CredentialType.PASSWORD_ONLY, password="password" ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "", CredentialType.PASSWORD_ONLY, password="password" ) def test_create_credential_missing_credential_type(self): with self.assertRaises(RequiredArgument): Credentials.create_credential("name", None) with self.assertRaises(RequiredArgument): Credentials.create_credential("name", "") def test_create_credential_invalid_credential_type(self): with self.assertRaises(InvalidArgument): Credentials.create_credential("name", "invalid") def test_create_credential_username_password(self): request = Credentials.create_credential( "name", CredentialType.USERNAME_PASSWORD, login="username", password="password", ) self.assertEqual( bytes(request), b"" b"name" b"up" b"username" b"password" b"", ) def test_create_credential_username_password_auto_generate_password(self): request = Credentials.create_credential( "name", CredentialType.USERNAME_PASSWORD, login="username", ) self.assertEqual( bytes(request), b"" b"name" b"up" b"username" b"", ) def test_create_username_password_credential_with_allow_insecure(self): request = Credentials.create_credential( "name", CredentialType.USERNAME_PASSWORD, login="username", password="password", allow_insecure=True, ) self.assertEqual( bytes(request), b"" b"name" b"up" b"1" b"username" b"password" b"", ) def test_create_credential_username_password_with_comment(self): request = Credentials.create_credential( "name", CredentialType.USERNAME_PASSWORD, login="username", password="password", comment="comment", ) self.assertEqual( bytes(request), b"" b"name" b"up" b"comment" b"username" b"password" b"", ) def test_create_credential_username_password_missing_login(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.USERNAME_PASSWORD, password="password" ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.USERNAME_PASSWORD, login="", password="password", ) def test_create_credential_client_certificate(self): request = Credentials.create_credential( "name", CredentialType.CLIENT_CERTIFICATE, certificate="certificate", ) self.assertEqual( bytes(request), b"" b"name" b"cc" b"certificate" b"", ) def test_create_credential_client_certificate_with_private_key(self): request = Credentials.create_credential( "name", CredentialType.CLIENT_CERTIFICATE, certificate="certificate", private_key="private_key", ) self.assertEqual( bytes(request), b"" b"name" b"cc" b"certificate" b"" b"private_key" b"" b"", ) def test_create_credential_client_certificate_missing_certificate(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.CLIENT_CERTIFICATE ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.CLIENT_CERTIFICATE, certificate="" ) def test_create_credential_username_ssh_key(self): request = Credentials.create_credential( "name", CredentialType.USERNAME_SSH_KEY, login="username", private_key="private", ) self.assertEqual( bytes(request), b"" b"name" b"usk" b"username" b"" b"private" b"" b"", ) def test_create_credential_username_ssh_key_with_passphrase(self): request = Credentials.create_credential( "name", CredentialType.USERNAME_SSH_KEY, login="username", private_key="private", key_phrase="passphrase", ) self.assertEqual( bytes(request), b"" b"name" b"usk" b"username" b"" b"private" b"passphrase" b"" b"", ) def test_create_credential_username_ssh_key_auto_generate_key(self): request = Credentials.create_credential( "name", CredentialType.USERNAME_SSH_KEY, login="username", ) self.assertEqual( bytes(request), b"" b"name" b"usk" b"username" b"", ) def test_create_credential_username_ssh_key_missing_private_key(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.USERNAME_SSH_KEY, login="username", private_key="", ) def test_create_credential_username_ssh_key_missing_login(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.USERNAME_SSH_KEY, private_key="private" ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.USERNAME_SSH_KEY, login="", private_key="private", ) def test_create_credential_snmp_with_auth_algorithm_md5(self): request = Credentials.create_credential( "name", CredentialType.SNMP, auth_algorithm=SnmpAuthAlgorithm.MD5, login="username", ) self.assertEqual( bytes(request), b"" b"name" b"snmp" b"username" b"md5" b"", ) def test_create_credential_snmp_with_auth_algorithm_sha1(self): request = Credentials.create_credential( "name", CredentialType.SNMP, auth_algorithm=SnmpAuthAlgorithm.SHA1, login="username", ) self.assertEqual( bytes(request), b"" b"name" b"snmp" b"username" b"sha1" b"", ) def test_create_credential_snmp_missing_auth_algorithm(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.SNMP, login="username" ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.SNMP, login="username", auth_algorithm=None, ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.SNMP, login="username", auth_algorithm="", ) def test_create_credential_snmp_missing_login(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.SNMP, auth_algorithm=SnmpAuthAlgorithm.MD5, ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.SNMP, auth_algorithm=SnmpAuthAlgorithm.MD5, login="", ) def test_create_credential_snmp_with_community(self): request = Credentials.create_credential( "name", CredentialType.SNMP, auth_algorithm=SnmpAuthAlgorithm.MD5, login="username", community="community", ) self.assertEqual( bytes(request), b"" b"name" b"snmp" b"username" b"md5" b"community" b"", ) def test_create_credential_snmp_with_password(self): request = Credentials.create_credential( "name", CredentialType.SNMP, auth_algorithm=SnmpAuthAlgorithm.MD5, login="username", password="password", ) self.assertEqual( bytes(request), b"" b"name" b"snmp" b"username" b"password" b"md5" b"", ) def test_create_credential_snmp_with_privacy_algorithm(self): request = Credentials.create_credential( "name", CredentialType.SNMP, auth_algorithm=SnmpAuthAlgorithm.MD5, login="username", privacy_algorithm=SnmpPrivacyAlgorithm.DES, ) self.assertEqual( bytes(request), b"" b"name" b"snmp" b"username" b"md5" b"" b"des" b"" b"", ) def test_create_credential_snmp_with_privacy_algorithm_and_privacy_password( self, ): request = Credentials.create_credential( "name", CredentialType.SNMP, auth_algorithm=SnmpAuthAlgorithm.MD5, login="username", privacy_algorithm=SnmpPrivacyAlgorithm.DES, privacy_password="password", ) self.assertEqual( bytes(request), b"" b"name" b"snmp" b"username" b"md5" b"" b"des" b"password" b"" b"", ) def test_create_credential_pgp(self): request = Credentials.create_credential( "name", CredentialType.PGP_ENCRYPTION_KEY, public_key="public_key", ) self.assertEqual( bytes(request), b"" b"name" b"pgp" b"" b"public_key" b"" b"", ) def test_create_credential_pgp_missing_key(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.PGP_ENCRYPTION_KEY ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.PGP_ENCRYPTION_KEY, public_key=None ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.PGP_ENCRYPTION_KEY, public_key="" ) def test_create_credential_password_only(self): request = Credentials.create_credential( "name", CredentialType.PASSWORD_ONLY, password="password", ) self.assertEqual( bytes(request), b"" b"name" b"pw" b"password" b"", ) def test_create_credential_password_only_missing_password(self): with self.assertRaises(RequiredArgument): Credentials.create_credential("name", CredentialType.PASSWORD_ONLY) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.PASSWORD_ONLY, password=None ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.PASSWORD_ONLY, password="" ) def test_create_credential_smime(self): request = Credentials.create_credential( "name", CredentialType.SMIME_CERTIFICATE, certificate="certificate", ) self.assertEqual( bytes(request), b"" b"name" b"smime" b"certificate" b"", ) def test_create_credential_smime_missing_certificate(self): with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.SMIME_CERTIFICATE, ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.SMIME_CERTIFICATE, certificate=None, ) with self.assertRaises(RequiredArgument): Credentials.create_credential( "name", CredentialType.SMIME_CERTIFICATE, certificate="", ) def test_delete_alert(self): request = Credentials.delete_credential("a1") self.assertEqual( bytes(request), b'', ) def test_delete_alert_with_ultimate(self): request = Credentials.delete_credential("a1", ultimate=False) self.assertEqual( bytes(request), b'', ) request = Credentials.delete_credential("a1", ultimate=True) self.assertEqual( bytes(request), b'', ) def test_delete_alert_missing_credential_id(self): with self.assertRaises(RequiredArgument): Credentials.delete_credential(None) with self.assertRaises(RequiredArgument): Credentials.delete_credential("") def test_get_credentials(self): request = Credentials.get_credentials() self.assertEqual( bytes(request), b"", ) def test_get_credentials_with_filter_string(self): request = Credentials.get_credentials(filter_string="name") self.assertEqual( bytes(request), b'', ) def test_get_credentials_with_scanners(self): request = Credentials.get_credentials(scanners=True) self.assertEqual( bytes(request), b'', ) def test_get_credentials_with_trash(self): request = Credentials.get_credentials(trash=True) self.assertEqual( bytes(request), b'', ) def test_get_credentials_with_targets(self): request = Credentials.get_credentials(targets=True) self.assertEqual( bytes(request), b'', ) def test_get_credential(self): request = Credentials.get_credential("a1") self.assertEqual( bytes(request), b'', ) def test_get_credential_with_scanners(self): request = Credentials.get_credential("a1", scanners=True) self.assertEqual( bytes(request), b'', ) def test_get_credential_with_targets(self): request = Credentials.get_credential("a1", targets=True) self.assertEqual( bytes(request), b'', ) def test_get_credential_with_credential_format(self): request = Credentials.get_credential("a1", credential_format="key") self.assertEqual( bytes(request), b'', ) request = Credentials.get_credential( "a1", credential_format=CredentialFormat.KEY ) self.assertEqual( bytes(request), b'', ) request = Credentials.get_credential( "a1", credential_format=CredentialFormat.EXE ) self.assertEqual( bytes(request), b'', ) request = Credentials.get_credential( "a1", credential_format=CredentialFormat.DEB ) self.assertEqual( bytes(request), b'', ) request = Credentials.get_credential( "a1", credential_format=CredentialFormat.PEM ) self.assertEqual( bytes(request), b'', ) request = Credentials.get_credential( "a1", credential_format=CredentialFormat.RPM ) self.assertEqual( bytes(request), b'', ) def test_get_credential_missing_credential_id(self): with self.assertRaises(RequiredArgument): Credentials.get_credential(None) with self.assertRaises(RequiredArgument): Credentials.get_credential("") def test_modify_credential_with_name(self): request = Credentials.modify_credential("a1", name="name") self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_credential_with_comment(self): request = Credentials.modify_credential("a1", comment="comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_credential_with_allow_insecure(self): request = Credentials.modify_credential("a1", allow_insecure=True) self.assertEqual( bytes(request), b'' b"1" b"", ) request = Credentials.modify_credential("a1", allow_insecure=False) self.assertEqual( bytes(request), b'' b"0" b"", ) def test_modify_credential_with_certificate(self): request = Credentials.modify_credential("a1", certificate="certificate") self.assertEqual( bytes(request), b'' b"certificate" b"", ) def test_modify_credential_with_key_phrase_and_private_key(self): request = Credentials.modify_credential( "a1", key_phrase="passphrase", private_key="private" ) self.assertEqual( bytes(request), b'' b"" b"passphrase" b"private" b"" b"", ) def test_modify_credential_missing_key_phrase_or_private_key(self): with self.assertRaises(RequiredArgument): Credentials.modify_credential("a1", key_phrase="passphrase") with self.assertRaises(RequiredArgument): Credentials.modify_credential("a1", private_key="private") def test_modify_credential_with_login(self): request = Credentials.modify_credential("a1", login="username") self.assertEqual( bytes(request), b'' b"username" b"", ) def test_modify_credential_with_password(self): request = Credentials.modify_credential("a1", password="password") self.assertEqual( bytes(request), b'' b"password" b"", ) def test_modify_credential_with_auth_algorithm(self): request = Credentials.modify_credential( "a1", auth_algorithm=SnmpAuthAlgorithm.MD5 ) self.assertEqual( bytes(request), b'' b"md5" b"", ) request = Credentials.modify_credential("a1", auth_algorithm="md5") self.assertEqual( bytes(request), b'' b"md5" b"", ) request = Credentials.modify_credential( "a1", auth_algorithm=SnmpAuthAlgorithm.SHA1 ) self.assertEqual( bytes(request), b'' b"sha1" b"", ) def test_modify_credential_with_community(self): request = Credentials.modify_credential("a1", community="community") self.assertEqual( bytes(request), b'' b"community" b"", ) def test_modify_credential_with_privacy_algorithm(self): request = Credentials.modify_credential( "a1", privacy_algorithm=SnmpPrivacyAlgorithm.DES ) self.assertEqual( bytes(request), b'' b"" b"des" b"" b"", ) request = Credentials.modify_credential("a1", privacy_algorithm="des") self.assertEqual( bytes(request), b'' b"" b"des" b"" b"", ) request = Credentials.modify_credential( "a1", privacy_algorithm=SnmpPrivacyAlgorithm.AES ) self.assertEqual( bytes(request), b'' b"" b"aes" b"" b"", ) def test_modify_credential_with_privacy_password(self): request = Credentials.modify_credential( "a1", privacy_password="password" ) self.assertEqual( bytes(request), b'' b"" b"password" b"" b"", ) def test_modify_credential_with_public_key(self): request = Credentials.modify_credential("a1", public_key="public_key") self.assertEqual( bytes(request), b'' b"" b"public_key" b"" b"", ) def test_modify_credential_missing_credential_id(self): with self.assertRaises(RequiredArgument): Credentials.modify_credential(None) with self.assertRaises(RequiredArgument): Credentials.modify_credential("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_cves.py000066400000000000000000000034571466406635600246400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Cves class CvesTestCase(unittest.TestCase): def test_get_cves(self): request = Cves.get_cves() self.assertEqual( bytes(request), b'', ) def test_get_cves_with_filter_string(self): request = Cves.get_cves(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_cves_with_filter_id(self): request = Cves.get_cves(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_cves_with_name(self): request = Cves.get_cves(name="name") self.assertEqual( bytes(request), b'', ) def test_get_cves_with_details(self): request = Cves.get_cves(details=True) self.assertEqual( bytes(request), b'', ) request = Cves.get_cves(details=False) self.assertEqual( bytes(request), b'', ) def test_get_cve(self): request = Cves.get_cve("cve_id") self.assertEqual( bytes(request), b'', ) def test_get_cve_missing_cve_id(self): with self.assertRaises(RequiredArgument): Cves.get_cve(None) with self.assertRaises(RequiredArgument): Cves.get_cve("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_dfn_cert_advisories.py000066400000000000000000000044271466406635600277120ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import DfnCertAdvisories class DfnCertAdvisoriesTestCase(unittest.TestCase): def test_get_dfn_cert_advisories(self): request = DfnCertAdvisories.get_dfn_cert_advisories() self.assertEqual( bytes(request), b'', ) def test_get_dfn_cert_advisories_with_filter_string(self): request = DfnCertAdvisories.get_dfn_cert_advisories( filter_string="filter_string" ) self.assertEqual( bytes(request), b'', ) def test_get_dfn_cert_advisories_with_filter_id(self): request = DfnCertAdvisories.get_dfn_cert_advisories( filter_id="filter_id" ) self.assertEqual( bytes(request), b'', ) def test_get_dfn_cert_advisories_with_name(self): request = DfnCertAdvisories.get_dfn_cert_advisories(name="name") self.assertEqual( bytes(request), b'', ) def test_get_dfn_cert_advisories_with_details(self): request = DfnCertAdvisories.get_dfn_cert_advisories(details=True) self.assertEqual( bytes(request), b'', ) request = DfnCertAdvisories.get_dfn_cert_advisories(details=False) self.assertEqual( bytes(request), b'', ) def test_get_dfn_cert_advisory(self): request = DfnCertAdvisories.get_dfn_cert_advisory("cert_id") self.assertEqual( bytes(request), b'', ) def test_get_dfn_cert_advisory_missing_cert_id(self): with self.assertRaises(RequiredArgument): DfnCertAdvisories.get_dfn_cert_advisory(None) with self.assertRaises(RequiredArgument): DfnCertAdvisories.get_dfn_cert_advisory("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_feed.py000066400000000000000000000027671466406635600246060ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Feed, FeedType class FeedTestCase(unittest.TestCase): def test_get_feed(self) -> None: """ Test basic get_feed calls with only resource_type except special cases for audit, policy, scan_config and task. """ request = Feed.get_feed(FeedType.NVT) self.assertEqual(bytes(request), b'') request = Feed.get_feed(FeedType.CERT) self.assertEqual(bytes(request), b'') request = Feed.get_feed(FeedType.SCAP) self.assertEqual(bytes(request), b'') request = Feed.get_feed(FeedType.GVMD_DATA) self.assertEqual(bytes(request), b'') def test_get_feed_missing_type(self): """ Test get_feed calls with missing resource_type """ with self.assertRaises(RequiredArgument): Feed.get_feed(feed_type=None) with self.assertRaises(RequiredArgument): Feed.get_feed(feed_type="") with self.assertRaises(RequiredArgument): Feed.get_feed("") def test_get_feed_invalid_type(self): """ Test get_feed calls with invalid resource_type """ with self.assertRaises(InvalidArgument): Feed.get_feed("foo") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_filters.py000066400000000000000000000170301466406635600253400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Filters, FilterType class FilterTestsCase(unittest.TestCase): def test_clone_filter(self): request = Filters.clone_filter("filter_id") self.assertEqual( bytes(request), b"filter_id", ) def test_clone_filter_missing_filter_id(self): with self.assertRaises(RequiredArgument): Filters.clone_filter(None) with self.assertRaises(RequiredArgument): Filters.clone_filter("") def test_create_filter(self): request = Filters.create_filter("filter_name") self.assertEqual( bytes(request), b"filter_name", ) def test_create_filter_with_comment(self): request = Filters.create_filter("filter_name", comment="comment") self.assertEqual( bytes(request), b"" b"filter_name" b"comment" b"", ) def test_create_filter_with_term(self): request = Filters.create_filter("filter_name", term="term") self.assertEqual( bytes(request), b"" b"filter_name" b"term" b"", ) def test_create_filter_with_filter_type(self): request = Filters.create_filter( "filter_name", filter_type=FilterType.ALERT ) self.assertEqual( bytes(request), b"" b"filter_name" b"alert" b"", ) request = Filters.create_filter( "filter_name", filter_type="alert", ) self.assertEqual( bytes(request), b"" b"filter_name" b"alert" b"", ) def test_create_filter_invalid_filter_type(self): with self.assertRaises(InvalidArgument): Filters.create_filter("filter_name", filter_type="invalid") def test_create_filter_missing_name(self): with self.assertRaises(RequiredArgument): Filters.create_filter(None) with self.assertRaises(RequiredArgument): Filters.create_filter("") def test_delete_filter(self): request = Filters.delete_filter("filter_id") self.assertEqual( bytes(request), b'', ) def test_delete_filter_with_ultimate(self): request = Filters.delete_filter("filter_id", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Filters.delete_filter("filter_id", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_filter_missing_filter_id(self): with self.assertRaises(RequiredArgument): Filters.delete_filter(None) with self.assertRaises(RequiredArgument): Filters.delete_filter("") def test_get_filters(self): request = Filters.get_filters() self.assertEqual( bytes(request), b"", ) def test_get_filters_with_filter_string(self): request = Filters.get_filters(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_filters_with_filter_id(self): request = Filters.get_filters(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_filters_with_trash(self): request = Filters.get_filters(trash=True) self.assertEqual( bytes(request), b'', ) request = Filters.get_filters(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_filters_with_alerts(self): request = Filters.get_filters(alerts=True) self.assertEqual( bytes(request), b'', ) request = Filters.get_filters(alerts=False) self.assertEqual( bytes(request), b'', ) def test_get_filter(self): request = Filters.get_filter("filter_id") self.assertEqual( bytes(request), b'', ) def test_get_filter_with_alerts(self): request = Filters.get_filter("filter_id", alerts=True) self.assertEqual( bytes(request), b'', ) request = Filters.get_filter("filter_id", alerts=False) self.assertEqual( bytes(request), b'', ) def test_get_filter_missing_filter_id(self): with self.assertRaises(RequiredArgument): Filters.get_filter(None) with self.assertRaises(RequiredArgument): Filters.get_filter("") def test_modify_filter(self): request = Filters.modify_filter("filter_id") self.assertEqual( bytes(request), b'', ) def test_modify_filter_with_comment(self): request = Filters.modify_filter("filter_id", comment="comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_filter_with_name(self): request = Filters.modify_filter("filter_id", name="name") self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_filter_with_term(self): request = Filters.modify_filter("filter_id", term="term") self.assertEqual( bytes(request), b'' b"term" b"", ) def test_modify_filter_with_type(self): request = Filters.modify_filter( "filter_id", filter_type=FilterType.ALERT ) self.assertEqual( bytes(request), b'' b"alert" b"", ) request = Filters.modify_filter("filter_id", filter_type="alert") self.assertEqual( bytes(request), b'' b"alert" b"", ) def test_modify_filter_missing_filter_id(self): with self.assertRaises(RequiredArgument): Filters.modify_filter(None) with self.assertRaises(RequiredArgument): Filters.modify_filter("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_groups.py000066400000000000000000000133571466406635600252170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Groups class GroupsTestCase(unittest.TestCase): def test_clone_group(self): request = Groups.clone_group("group_id") self.assertEqual( bytes(request), b"group_id", ) def test_clone_group_missing_group_id(self): with self.assertRaises(RequiredArgument): Groups.clone_group(None) with self.assertRaises(RequiredArgument): Groups.clone_group("") def test_create_group(self): request = Groups.create_group("group_name") self.assertEqual( bytes(request), b"group_name", ) def test_create_group_with_comment(self): request = Groups.create_group("group_name", comment="comment") self.assertEqual( bytes(request), b"" b"group_name" b"comment" b"", ) def test_create_group_with_special(self): request = Groups.create_group("group_name", special=True) self.assertEqual( bytes(request), b"" b"group_name" b"" b"", ) request = Groups.create_group("group_name", special=False) self.assertEqual( bytes(request), b"group_name", ) def test_create_group_with_users(self): request = Groups.create_group("group_name", users=["user1", "user2"]) self.assertEqual( bytes(request), b"" b"group_name" b"user1,user2" b"", ) def test_create_group_missing_name(self): with self.assertRaises(RequiredArgument): Groups.create_group(None) with self.assertRaises(RequiredArgument): Groups.create_group("") def test_delete_group(self): request = Groups.delete_group("group_id") self.assertEqual( bytes(request), b'', ) def test_delete_group_with_ultimate(self): request = Groups.delete_group("group_id", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Groups.delete_group("group_id", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_group_missing_group_id(self): with self.assertRaises(RequiredArgument): Groups.delete_group(None) with self.assertRaises(RequiredArgument): Groups.delete_group("") def test_get_groups(self): request = Groups.get_groups() self.assertEqual( bytes(request), b"", ) def test_get_groups_with_filter_string(self): request = Groups.get_groups(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_groups_with_filter_id(self): request = Groups.get_groups(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_groups_with_trash(self): request = Groups.get_groups(trash=True) self.assertEqual( bytes(request), b'', ) request = Groups.get_groups(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_group(self): request = Groups.get_group("group_id") self.assertEqual( bytes(request), b'', ) def test_group_missing_group_id(self): with self.assertRaises(RequiredArgument): Groups.get_group(None) with self.assertRaises(RequiredArgument): Groups.get_group("") def test_modify_group(self): request = Groups.modify_group("group_id") self.assertEqual( bytes(request), b'', ) def test_modify_group_with_comment(self): request = Groups.modify_group("group_id", comment="comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_group_with_name(self): request = Groups.modify_group("group_id", name="name") self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_group_with_users(self): request = Groups.modify_group("group_id", users=["user1", "user2"]) self.assertEqual( bytes(request), b'' b"user1,user2" b"", ) def test_modify_group_missing_group_id(self): with self.assertRaises(RequiredArgument): Groups.modify_group(None) with self.assertRaises(RequiredArgument): Groups.modify_group("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_help.py000066400000000000000000000014471466406635600246250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 import Help, HelpFormat class HelpTestCase(unittest.TestCase): def test_help(self): request = Help.help() self.assertEqual(bytes(request), b'') def test_help_type_brief(self): request = Help.help(brief=True) self.assertEqual(bytes(request), b'') def test_invalid_help_format(self): with self.assertRaises(InvalidArgument): Help.help(help_format="foo") def test_html_format(self): request = Help.help(help_format=HelpFormat.HTML) self.assertEqual(bytes(request), b'') python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_hosts.py000066400000000000000000000101251466406635600250260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Hosts class HostsTestCase(unittest.TestCase): def test_create_host(self): request = Hosts.create_host("host_name") self.assertEqual( bytes(request), b"" b"host" b"host_name" b"", ) def test_create_host_with_comment(self): request = Hosts.create_host("host_name", comment="comment") self.assertEqual( bytes(request), b"" b"host" b"host_name" b"comment" b"", ) def test_create_host_missing_name(self): with self.assertRaises(RequiredArgument): Hosts.create_host(None) with self.assertRaises(RequiredArgument): Hosts.create_host("") def test_delete_host(self): request = Hosts.delete_host("host_id") self.assertEqual( bytes(request), b'', ) def test_delete_host_missing_host_id(self): with self.assertRaises(RequiredArgument): Hosts.delete_host(None) with self.assertRaises(RequiredArgument): Hosts.delete_host("") def test_get_hosts(self): request = Hosts.get_hosts() self.assertEqual( bytes(request), b'', ) def test_get_hosts_with_filter_string(self): request = Hosts.get_hosts(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_hosts_with_filter_id(self): request = Hosts.get_hosts(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_hosts_with_details(self): request = Hosts.get_hosts(details=True) self.assertEqual( bytes(request), b'', ) request = Hosts.get_hosts(details=False) self.assertEqual( bytes(request), b'', ) def test_get_host(self): request = Hosts.get_host("host_id") self.assertEqual( bytes(request), b'', ) def test_get_host_with_details(self): request = Hosts.get_host("host_id", details=True) self.assertEqual( bytes(request), b'', ) request = Hosts.get_host("host_id", details=False) self.assertEqual( bytes(request), b'', ) def test_get_host_missing_host_id(self): with self.assertRaises(RequiredArgument): Hosts.get_host(None) with self.assertRaises(RequiredArgument): Hosts.get_host("") def test_modify_host(self): request = Hosts.modify_host("host_id") self.assertEqual( bytes(request), b'' b"" b"", ) def test_modify_host_with_comment(self): request = Hosts.modify_host("host_id", comment="comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_host_missing_host_id(self): with self.assertRaises(RequiredArgument): Hosts.modify_host(None) with self.assertRaises(RequiredArgument): Hosts.modify_host("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_notes.py000066400000000000000000000247311466406635600250260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from decimal import Decimal from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Notes class NotesTestCase(unittest.TestCase): def test_create_note(self): request = Notes.create_note("foo", nvt_oid="oid1") self.assertEqual( bytes(request), b"" b"foo" b'' b"", ) def test_create_note_missing_text(self): with self.assertRaises(RequiredArgument): Notes.create_note(None, "od1") with self.assertRaises(RequiredArgument): Notes.create_note("", "oid1") def test_create_note_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): Notes.create_note("foo", None) with self.assertRaises(RequiredArgument): Notes.create_note("foo", "") def test_create_note_with_hosts(self): request = Notes.create_note("foo", nvt_oid="oid1", hosts=[]) self.assertEqual( bytes(request), b"" b"foo" b'' b"", ) request = Notes.create_note("foo", nvt_oid="oid1", hosts=["h1", "h2"]) self.assertEqual( bytes(request), b"" b"foo" b'' b"h1,h2" b"", ) def test_create_note_with_port(self): request = Notes.create_note("foo", nvt_oid="oid1", port="666/tcp") self.assertEqual( bytes(request), b"" b"foo" b'' b"666/tcp" b"", ) def test_create_note_with_result_id(self): request = Notes.create_note("foo", nvt_oid="oid1", result_id="r1") self.assertEqual( bytes(request), b"" b"foo" b'' b'' b"", ) def test_create_note_with_task_id(self): request = Notes.create_note("foo", nvt_oid="oid1", task_id="t1") self.assertEqual( bytes(request), b"" b"foo" b'' b'' b"", ) def test_create_note_with_severity(self): request = Notes.create_note("foo", nvt_oid="oid1", severity="5.5") self.assertEqual( bytes(request), b"" b"foo" b'' b"5.5" b"", ) def test_create_note_with_days_active(self): request = Notes.create_note("foo", nvt_oid="oid1", days_active=5) self.assertEqual( bytes(request), b"" b"foo" b'' b"5" b"", ) def test_create_note_with_invalid_port(self): with self.assertRaises(InvalidArgument): Notes.create_note("foo", nvt_oid="oid1", port="666") with self.assertRaises(InvalidArgument): Notes.create_note("foo", nvt_oid="oid1", port="666/") with self.assertRaises(InvalidArgument): Notes.create_note("foo", nvt_oid="oid1", port="udp/666") def test_modify_note(self): request = Notes.modify_note("n1", "foo") self.assertEqual( bytes(request), b'foo', ) def test_modify_note_missing_note_id(self): with self.assertRaises(RequiredArgument): Notes.modify_note(None, "foo") with self.assertRaises(RequiredArgument): Notes.modify_note("", "foo") def test_modify_note_missing_text(self): with self.assertRaises(RequiredArgument): Notes.modify_note("n1", None) with self.assertRaises(RequiredArgument): Notes.modify_note("n1", "") def test_modify_note_with_days_active(self): request = Notes.modify_note("n1", "foo", days_active=0) self.assertEqual( bytes(request), b'' b"foo" b"0" b"", ) request = Notes.modify_note("n1", "foo", days_active=-1) self.assertEqual( bytes(request), b'' b"foo" b"-1" b"", ) request = Notes.modify_note("n1", "foo", days_active=600) self.assertEqual( bytes(request), b'' b"foo" b"600" b"", ) def test_modify_note_with_port(self): request = Notes.modify_note("n1", "foo", port="123/tcp") self.assertEqual( bytes(request), b'' b"foo" b"123/tcp" b"", ) def test_modify_note_with_hosts(self): request = Notes.modify_note("n1", "foo", hosts=["h1"]) self.assertEqual( bytes(request), b'' b"foo" b"h1" b"", ) request = Notes.modify_note("n1", "foo", hosts=["h1", "h2"]) self.assertEqual( bytes(request), b'' b"foo" b"h1,h2" b"", ) def test_modify_note_with_result_id(self): request = Notes.modify_note("n1", "foo", result_id="r1") self.assertEqual( bytes(request), b'' b"foo" b'' b"", ) def test_modify_note_with_task_id(self): request = Notes.modify_note("n1", "foo", task_id="t1") self.assertEqual( bytes(request), b'' b"foo" b'' b"", ) def test_modify_note_with_severity(self): request = Notes.modify_note("n1", "foo", severity="5.5") self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) request = Notes.modify_note("n1", "foo", severity=5.5) self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) request = Notes.modify_note("n1", "foo", severity=Decimal(5.5)) self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) def test_modify_note_with_invalid_port(self): with self.assertRaises(InvalidArgument): Notes.modify_note("n1", "foo", port="666") with self.assertRaises(InvalidArgument): Notes.modify_note("n1", "foo", port="666/") with self.assertRaises(InvalidArgument): Notes.modify_note("n1", "foo", port="udp/666") def test_clone_note(self): request = Notes.clone_note("n1") self.assertEqual( bytes(request), b"n1", ) def test_clone_note_missing_note_id(self): with self.assertRaises(RequiredArgument): Notes.clone_note(None) with self.assertRaises(RequiredArgument): Notes.clone_note("") def test_delete_note(self): request = Notes.delete_note("n1") self.assertEqual( bytes(request), b'' ) def test_delete_note_ultimate(self): request = Notes.delete_note("n1", ultimate=True) self.assertEqual( bytes(request), b'' ) request = Notes.delete_note("n1", ultimate=False) self.assertEqual( bytes(request), b'' ) def test_delete_note_missing_note_id(self): with self.assertRaises(RequiredArgument): Notes.delete_note(None) with self.assertRaises(RequiredArgument): Notes.delete_note("") def test_get_notes(self): request = Notes.get_notes() self.assertEqual(bytes(request), b"") def test_get_notes_with_filter_string(self): request = Notes.get_notes(filter_string="foo=bar") self.assertEqual(bytes(request), b'') def test_get_notes_with_filter_id(self): request = Notes.get_notes(filter_id="f1") self.assertEqual(bytes(request), b'') def test_get_notes_with_details(self): request = Notes.get_notes(details=True) self.assertEqual(bytes(request), b'') request = Notes.get_notes(details=False) self.assertEqual(bytes(request), b'') def test_get_notes_with_result(self): request = Notes.get_notes(result=True) self.assertEqual(bytes(request), b'') request = Notes.get_notes(result=False) self.assertEqual(bytes(request), b'') def test_get_note(self): request = Notes.get_note("n1") self.assertEqual( bytes(request), b'' ) def test_get_note_missing_note_id(self): with self.assertRaises(RequiredArgument): Notes.get_note(None) with self.assertRaises(RequiredArgument): Notes.get_note("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_nvts.py000066400000000000000000000205121466406635600246610ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Nvts class NvtsTestCase(unittest.TestCase): def test_get_nvt_families(self): request = Nvts.get_nvt_families() self.assertEqual( bytes(request), b"", ) def test_get_nvt_families_with_sort_order(self): request = Nvts.get_nvt_families(sort_order="sort_order") self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts(self): request = Nvts.get_scan_config_nvts() self.assertEqual( bytes(request), b"", ) def test_get_scan_config_nvts_with_details(self): request = Nvts.get_scan_config_nvts(details=True) self.assertEqual( bytes(request), b'', ) request = Nvts.get_scan_config_nvts(details=False) self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts_with_preferences(self): request = Nvts.get_scan_config_nvts(preferences=True) self.assertEqual( bytes(request), b'', ) request = Nvts.get_scan_config_nvts(preferences=False) self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts_with_preference_count(self): request = Nvts.get_scan_config_nvts(preference_count=True) self.assertEqual( bytes(request), b'', ) request = Nvts.get_scan_config_nvts(preference_count=False) self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts_with_timeout(self): request = Nvts.get_scan_config_nvts(timeout=True) self.assertEqual( bytes(request), b'', ) request = Nvts.get_scan_config_nvts(timeout=False) self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts_with_config_id(self): request = Nvts.get_scan_config_nvts(config_id="config_id") self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts_with_preferences_config_id(self): request = Nvts.get_scan_config_nvts( preferences_config_id="preferences_config_id" ) self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts_with_family(self): request = Nvts.get_scan_config_nvts(family="family") self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts_with_sort_order(self): request = Nvts.get_scan_config_nvts(sort_order="sort_order") self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvts_with_sort_field(self): request = Nvts.get_scan_config_nvts(sort_field="sort_field") self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvt(self): request = Nvts.get_scan_config_nvt("nvt_oid") self.assertEqual( bytes(request), b'', ) def test_get_scan_config_nvt_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): Nvts.get_scan_config_nvt(None) with self.assertRaises(RequiredArgument): Nvts.get_scan_config_nvt("") def test_get_nvts(self): request = Nvts.get_nvts() self.assertEqual( bytes(request), b'', ) def test_get_nvts_with_name(self): request = Nvts.get_nvts(name="name") self.assertEqual( bytes(request), b'', ) def test_get_nvts_with_details(self): request = Nvts.get_nvts(details=True) self.assertEqual( bytes(request), b'', ) request = Nvts.get_nvts(details=False) self.assertEqual( bytes(request), b'', ) def test_get_nvts_with_extended(self): request = Nvts.get_nvts(extended=True) self.assertEqual( bytes(request), b"", ) request = Nvts.get_nvts(extended=False) self.assertEqual( bytes(request), b'', ) request = Nvts.get_nvts( extended=False, details=True, preferences=True, # gets ignored preference_count=True, # gets ignored timeout=True, # gets ignored config_id="config_id", # gets ignored preferences_config_id="preferences_config_id", # gets ignored family="family", # gets ignored sort_order="sort_order", # gets ignored sort_field="sort_field", # gets ignored ) self.assertEqual(bytes(request), b'') request = Nvts.get_nvts( extended=True, details=True, preferences=True, preference_count=True, timeout=True, config_id="config_id", preferences_config_id="preferences_config_id", family="family", sort_order="sort_order", sort_field="sort_field", ) self.assertEqual( bytes(request), b'', ) def test_get_nvt(self): request = Nvts.get_nvt("nvt_id") self.assertEqual( bytes(request), b'', ) def test_get_nvt_with_extended(self): request = Nvts.get_nvt("nvt_id", extended=True) self.assertEqual( bytes(request), b'', ) request = Nvts.get_nvt("nvt_id", extended=False) self.assertEqual( bytes(request), b'', ) def test_get_nvts_missing_nvt_id(self): with self.assertRaises(RequiredArgument): Nvts.get_nvt(None) with self.assertRaises(RequiredArgument): Nvts.get_nvt("") def test_get_nvt_preferences(self): request = Nvts.get_nvt_preferences() self.assertEqual( bytes(request), b"", ) def test_get_nvt_preferences_with_nvt_oid(self): request = Nvts.get_nvt_preferences(nvt_oid="nvt_oid") self.assertEqual( bytes(request), b'', ) def test_get_nvt_preference(self): request = Nvts.get_nvt_preference("preference") self.assertEqual( bytes(request), b'', ) def test_get_nvt_preference_with_nvt_oid(self): request = Nvts.get_nvt_preference("preference", nvt_oid="nvt_oid") self.assertEqual( bytes(request), b'', ) def test_get_nvt_preference_missing_name(self): with self.assertRaises(RequiredArgument): Nvts.get_nvt_preference(None) with self.assertRaises(RequiredArgument): Nvts.get_nvt_preference("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_operating_systems.py000066400000000000000000000074411466406635600274540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import OperatingSystems class OperatingSystemsTestCase(unittest.TestCase): def test_delete_operating_system(self): request = OperatingSystems.delete_operating_system( "operating_system_id" ) self.assertEqual( bytes(request), b'', ) def test_delete_operating_system_missing_operating_system_id(self): with self.assertRaises(RequiredArgument): OperatingSystems.delete_operating_system(None) with self.assertRaises(RequiredArgument): OperatingSystems.delete_operating_system("") def test_get_operating_systems(self): request = OperatingSystems.get_operating_systems() self.assertEqual( bytes(request), b'', ) def test_get_operating_systems_with_filter_string(self): request = OperatingSystems.get_operating_systems( filter_string="filter_string" ) self.assertEqual( bytes(request), b'', ) def test_get_operating_systems_with_filter_id(self): request = OperatingSystems.get_operating_systems(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_operating_systems_with_details(self): request = OperatingSystems.get_operating_systems(details=True) self.assertEqual( bytes(request), b'', ) request = OperatingSystems.get_operating_systems(details=False) self.assertEqual( bytes(request), b'', ) def test_get_operating_system(self): request = OperatingSystems.get_operating_system("operating_system_id") self.assertEqual( bytes(request), b'', ) def test_get_operating_system_with_details(self): request = OperatingSystems.get_operating_system( "operating_system_id", details=True ) self.assertEqual( bytes(request), b'', ) request = OperatingSystems.get_operating_system( "operating_system_id", details=False ) self.assertEqual( bytes(request), b'', ) def test_modify_operating_system(self): request = OperatingSystems.modify_operating_system( "operating_system_id" ) self.assertEqual( bytes(request), b'' b"" b"", ) def test_modify_operating_system_with_comment(self): request = OperatingSystems.modify_operating_system( "operating_system_id", comment="comment" ) self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_operating_system_missing_operating_system_id(self): with self.assertRaises(RequiredArgument): OperatingSystems.modify_operating_system(None) with self.assertRaises(RequiredArgument): OperatingSystems.modify_operating_system("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_overrides.py000066400000000000000000000357061466406635600257040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from decimal import Decimal from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Overrides class OverridesTestCase(unittest.TestCase): def test_create_override(self): request = Overrides.create_override("foo", nvt_oid="oid1") self.assertEqual( bytes(request), b"" b"foo" b'' b"", ) def test_create_override_missing_text(self): with self.assertRaises(RequiredArgument): Overrides.create_override(None, "od1") with self.assertRaises(RequiredArgument): Overrides.create_override("", "oid1") def test_create_override_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): Overrides.create_override("foo", None) with self.assertRaises(RequiredArgument): Overrides.create_override("foo", "") def test_create_override_with_hosts(self): request = Overrides.create_override("foo", nvt_oid="oid1", hosts=[]) self.assertEqual( bytes(request), b"" b"foo" b'' b"", ) request = Overrides.create_override( "foo", nvt_oid="oid1", hosts=["h1", "h2"] ) self.assertEqual( bytes(request), b"" b"foo" b'' b"h1,h2" b"", ) def test_create_override_with_port(self): request = Overrides.create_override( "foo", nvt_oid="oid1", port="666/udp" ) self.assertEqual( bytes(request), b"" b"foo" b'' b"666/udp" b"", ) def test_create_override_with_result_id(self): request = Overrides.create_override( "foo", nvt_oid="oid1", result_id="r1" ) self.assertEqual( bytes(request), b"" b"foo" b'' b'' b"", ) def test_create_override_with_task_id(self): request = Overrides.create_override("foo", nvt_oid="oid1", task_id="t1") self.assertEqual( bytes(request), b"" b"foo" b'' b'' b"", ) def test_create_override_with_severity(self): request = Overrides.create_override( "foo", nvt_oid="oid1", severity="5.5" ) self.assertEqual( bytes(request), b"" b"foo" b'' b"5.5" b"", ) request = Overrides.create_override("foo", nvt_oid="oid1", severity=5.5) self.assertEqual( bytes(request), b"" b"foo" b'' b"5.5" b"", ) request = Overrides.create_override( "foo", nvt_oid="oid1", severity=Decimal(5.5) ) self.assertEqual( bytes(request), b"" b"foo" b'' b"5.5" b"", ) def test_create_override_with_new_severity(self): request = Overrides.create_override( "foo", nvt_oid="oid1", new_severity="5.5" ) self.assertEqual( bytes(request), b"" b"foo" b'' b"5.5" b"", ) request = Overrides.create_override( "foo", nvt_oid="oid1", new_severity=5.5 ) self.assertEqual( bytes(request), b"" b"foo" b'' b"5.5" b"", ) request = Overrides.create_override( "foo", nvt_oid="oid1", new_severity=Decimal(5.5) ) self.assertEqual( bytes(request), b"" b"foo" b'' b"5.5" b"", ) def test_create_override_with_days_active(self): request = Overrides.create_override( "foo", nvt_oid="oid1", days_active=0 ) self.assertEqual( bytes(request), b"" b"foo" b'' b"0" b"", ) request = Overrides.create_override( "foo", nvt_oid="oid1", days_active=5 ) self.assertEqual( bytes(request), b"" b"foo" b'' b"5" b"", ) request = Overrides.create_override( "foo", nvt_oid="oid1", days_active=-1 ) self.assertEqual( bytes(request), b"" b"foo" b'' b"-1" b"", ) def test_create_override_with_invalid_port(self): with self.assertRaises(InvalidArgument): Overrides.create_override("foo", nvt_oid="oid1", port="invalid") with self.assertRaises(InvalidArgument): Overrides.create_override("foo", nvt_oid="oid1", port="123") with self.assertRaises(InvalidArgument): Overrides.create_override( text="foo", nvt_oid="oid1", port="tcp/123" ) def test_modify_override(self): request = Overrides.modify_override("o1", "foo") self.assertEqual( bytes(request), b'' b"foo" b"", ) def test_modify_override_missing_override_id(self): with self.assertRaises(RequiredArgument): Overrides.modify_override(None, "foo") with self.assertRaises(RequiredArgument): Overrides.modify_override("", "foo") def test_modify_override_missing_text(self): with self.assertRaises(RequiredArgument): Overrides.modify_override("o1", None) with self.assertRaises(RequiredArgument): Overrides.modify_override("o1", "") def test_modify_override_with_days_active(self): request = Overrides.modify_override("o1", "foo", days_active=0) self.assertEqual( bytes(request), b'' b"foo" b"0" b"", ) request = Overrides.modify_override("o1", "foo", days_active=5) self.assertEqual( bytes(request), b'' b"foo" b"5" b"", ) request = Overrides.modify_override("o1", "foo", days_active=-1) self.assertEqual( bytes(request), b'' b"foo" b"-1" b"", ) def test_modify_override_with_port(self): request = Overrides.modify_override("o1", "foo", port="666/udp") self.assertEqual( bytes(request), b'' b"foo" b"666/udp" b"", ) def test_modify_override_with_hosts(self): request = Overrides.modify_override("o1", "foo", hosts=["h1"]) self.assertEqual( bytes(request), b'' b"foo" b"h1" b"", ) request = Overrides.modify_override("o1", "foo", hosts=["h1", "h2"]) self.assertEqual( bytes(request), b'' b"foo" b"h1,h2" b"", ) def test_modify_override_with_result_id(self): request = Overrides.modify_override("o1", "foo", result_id="r1") self.assertEqual( bytes(request), b'' b"foo" b'' b"", ) def test_modify_override_with_task_id(self): request = Overrides.modify_override("o1", "foo", task_id="t1") self.assertEqual( bytes(request), b'' b"foo" b'' b"", ) def test_modify_override_with_severity(self): request = Overrides.modify_override("o1", "foo", severity="5.5") self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) request = Overrides.modify_override("o1", "foo", severity=5.5) self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) request = Overrides.modify_override("o1", "foo", severity=Decimal(5.5)) self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) def test_modify_override_with_new_severity(self): request = Overrides.modify_override("o1", "foo", new_severity="5.5") self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) request = Overrides.modify_override("o1", "foo", new_severity=5.5) self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) request = Overrides.modify_override( "o1", "foo", new_severity=Decimal(5.5) ) self.assertEqual( bytes(request), b'' b"foo" b"5.5" b"", ) def test_modify_override_with_invalid_port(self): with self.assertRaises(InvalidArgument): Overrides.modify_override("o1", "foo", port="invalid") with self.assertRaises(InvalidArgument): Overrides.modify_override("o1", "foo", port="123") with self.assertRaises(InvalidArgument): Overrides.modify_override("o1", "foo", port="tcp/123") def test_clone_override(self): request = Overrides.clone_override("o1") self.assertEqual( bytes(request), b"o1", ) def test_clone_override_missing_override_id(self): with self.assertRaises(RequiredArgument): Overrides.clone_override(None) with self.assertRaises(RequiredArgument): Overrides.clone_override("") def test_delete_override(self): request = Overrides.delete_override("o1") self.assertEqual( bytes(request), b'', ) def test_delete_override_ultimate(self): request = Overrides.delete_override("o1", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Overrides.delete_override("o1", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_override_missing_override_id(self): with self.assertRaises(RequiredArgument): Overrides.delete_override(None) with self.assertRaises(RequiredArgument): Overrides.delete_override("") def test_get_overrides(self): request = Overrides.get_overrides() self.assertEqual( bytes(request), b"", ) def test_get_overrides_with_filter_string(self): request = Overrides.get_overrides(filter_string="foo=bar") self.assertEqual(bytes(request), b'') def test_get_overrides_with_filter_id(self): request = Overrides.get_overrides(filter_id="f1") self.assertEqual(bytes(request), b'') def test_get_overrides_with_details(self): request = Overrides.get_overrides(details=True) self.assertEqual(bytes(request), b'') request = Overrides.get_overrides(details=False) self.assertEqual(bytes(request), b'') def test_get_overrides_with_result(self): request = Overrides.get_overrides(result=True) self.assertEqual(bytes(request), b'') request = Overrides.get_overrides(result=False) self.assertEqual(bytes(request), b'') def test_get_override(self): request = Overrides.get_override("o1") self.assertEqual( bytes(request), b'', ) def test_get_override_missing_override_id(self): with self.assertRaises(RequiredArgument): Overrides.get_override(None) with self.assertRaises(RequiredArgument): Overrides.get_override("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_permissions.py000066400000000000000000000245121466406635600262460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Permissions, PermissionSubjectType class PermissionsTestCase(unittest.TestCase): def test_clone_permission(self): request = Permissions.clone_permission("permission_id") self.assertEqual( bytes(request), b"permission_id", ) def test_clone_permission_missing_permission_id(self): with self.assertRaises(RequiredArgument): Permissions.clone_permission(None) with self.assertRaises(RequiredArgument): Permissions.clone_permission("") def test_create_permission(self): request = Permissions.create_permission( "name", "subject_id", PermissionSubjectType.USER ) self.assertEqual( bytes(request), b"" b"name" b'' b"user" b"" b"", ) request = Permissions.create_permission( "name", "subject_id", "user", ) self.assertEqual( bytes(request), b"" b"name" b'' b"user" b"" b"", ) def test_create_permission_with_resource(self): request = Permissions.create_permission( "name", "subject_id", PermissionSubjectType.USER, resource_id="resource_id", resource_type="alert", ) self.assertEqual( bytes(request), b"" b"name" b'' b"user" b"" b'' b"alert" b"" b"", ) def test_create_permission_with_comment(self): request = Permissions.create_permission( "name", "subject_id", PermissionSubjectType.USER, comment="comment", ) self.assertEqual( bytes(request), b"" b"name" b'' b"user" b"" b"comment" b"", ) def test_create_permission_missing_name(self): with self.assertRaises(RequiredArgument): Permissions.create_permission( None, "subject_id", PermissionSubjectType.USER ) with self.assertRaises(RequiredArgument): Permissions.create_permission( "", "subject_id", PermissionSubjectType.USER ) def test_create_permission_missing_subject_id(self): with self.assertRaises(RequiredArgument): Permissions.create_permission( "name", None, PermissionSubjectType.USER ) with self.assertRaises(RequiredArgument): Permissions.create_permission( "name", "", PermissionSubjectType.USER ) def test_create_permission_with_resource_missing_resource_id(self): with self.assertRaises(RequiredArgument): Permissions.create_permission( "name", "subject_id", PermissionSubjectType.USER, resource_type="alert", ) def test_create_permission_with_resource_missing_resource_type(self): with self.assertRaises(RequiredArgument): Permissions.create_permission( "name", "subject_id", PermissionSubjectType.USER, resource_id="resource_id", ) def test_create_permission_invalid_subject_type(self): with self.assertRaises(InvalidArgument): Permissions.create_permission("name", "subject_id", "invalid") def test_create_permission_invalid_resource_type(self): with self.assertRaises(InvalidArgument): Permissions.create_permission( "name", "subject_id", PermissionSubjectType.USER, resource_id="resource_id", resource_type="invalid", ) def test_delete_permission(self): request = Permissions.delete_permission("permission_id") self.assertEqual( bytes(request), b'', ) def test_delete_permission_ultimate(self): request = Permissions.delete_permission("permission_id", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Permissions.delete_permission("permission_id", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_permission_missing_permission_id(self): with self.assertRaises(RequiredArgument): Permissions.delete_permission(None) with self.assertRaises(RequiredArgument): Permissions.delete_permission("") def test_get_permissions(self): request = Permissions.get_permissions() self.assertEqual( bytes(request), b"", ) def test_get_permissions_with_filter_string(self): request = Permissions.get_permissions(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_permissions_with_filter_id(self): request = Permissions.get_permissions(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_permissions_with_trash(self): request = Permissions.get_permissions(trash=True) self.assertEqual( bytes(request), b'', ) request = Permissions.get_permissions(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_permission(self): request = Permissions.get_permission("permission_id") self.assertEqual( bytes(request), b'', ) def test_get_permission_missing_permission_id(self): with self.assertRaises(RequiredArgument): Permissions.get_permission(None) with self.assertRaises(RequiredArgument): Permissions.get_permission("") def test_modify_permission(self): request = Permissions.modify_permission("permission_id") self.assertEqual( bytes(request), b'', ) def test_modify_permission_with_name(self): request = Permissions.modify_permission("permission_id", name="name") self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_permission_with_comment(self): request = Permissions.modify_permission( "permission_id", comment="comment" ) self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_permission_with_resource(self): request = Permissions.modify_permission( "permission_id", resource_id="resource_id", resource_type="alert" ) self.assertEqual( bytes(request), b'' b'' b"alert" b"" b"", ) def test_modify_permission_with_subject(self): request = Permissions.modify_permission( "permission_id", subject_id="subject_id", subject_type="user" ) self.assertEqual( bytes(request), b'' b'' b"user" b"" b"", ) def test_modify_permission_with_resource_missing_resource_id(self): with self.assertRaises(RequiredArgument): Permissions.modify_permission( "permission_id", resource_type="alert" ) def test_modify_permission_with_resource_missing_resource_type(self): with self.assertRaises(RequiredArgument): Permissions.modify_permission( "permission_id", resource_id="resource_id" ) def test_modify_permission_with_subject_missing_subject_id(self): with self.assertRaises(RequiredArgument): Permissions.modify_permission("permission_id", subject_type="user") def test_modify_permission_with_subject_missing_subject_type(self): with self.assertRaises(RequiredArgument): Permissions.modify_permission( "permission_id", subject_id="subject_id" ) def test_modify_permission_invalid_resource_type(self): with self.assertRaises(InvalidArgument): Permissions.modify_permission( "permission_id", resource_id="resource_id", resource_type="invalid", ) def test_modify_permission_invalid_subject_type(self): with self.assertRaises(InvalidArgument): Permissions.modify_permission( "permission_id", subject_type="invalid", subject_id="subject_id" ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_policies.py000066400000000000000000000416041466406635600255030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Policies POLICY_XML_STRING = ( '' '' "Foobar" "Foobar config" "2018-11-09T10:48:03Z" "2018-11-09T10:48:03Z" "" "" ) class PoliciesTestCase(unittest.TestCase): def test_clone_policy(self): request = Policies.clone_policy("policy_id") self.assertEqual( bytes(request), b"policy_id", ) def test_clone_policy_missing_policy_id(self): with self.assertRaises(RequiredArgument): Policies.clone_policy(None) with self.assertRaises(RequiredArgument): Policies.clone_policy("") def test_create_policy(self): request = Policies.create_policy("name") self.assertEqual( bytes(request), b"" b"085569ce-73ed-11df-83c3-002264764cea" b"name" b"policy" b"", ) def test_create_policy_with_policy_id(self): request = Policies.create_policy("name", policy_id="policy_id") self.assertEqual( bytes(request), b"" b"policy_id" b"name" b"policy" b"", ) def test_create_policy_with_comment(self): request = Policies.create_policy("name", comment="comment") self.assertEqual( bytes(request), b"" b"comment" b"085569ce-73ed-11df-83c3-002264764cea" b"name" b"policy" b"", ) def test_delete_policy(self): request = Policies.delete_policy("policy_id") self.assertEqual( bytes(request), b'', ) def test_delete_policy_with_ultimate(self): request = Policies.delete_policy("policy_id", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Policies.delete_policy("policy_id", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_get_policies(self): request = Policies.get_policies() self.assertEqual( bytes(request), b'', ) def test_get_policies_with_trash(self): request = Policies.get_policies(trash=True) self.assertEqual( bytes(request), b'', ) request = Policies.get_policies(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_policies_with_details(self): request = Policies.get_policies(details=True) self.assertEqual( bytes(request), b'', ) request = Policies.get_policies(details=False) self.assertEqual( bytes(request), b'', ) def test_get_policies_with_families(self): request = Policies.get_policies(families=True) self.assertEqual( bytes(request), b'', ) request = Policies.get_policies(families=False) self.assertEqual( bytes(request), b'', ) def test_get_policies_with_preferences(self): request = Policies.get_policies(preferences=True) self.assertEqual( bytes(request), b'', ) request = Policies.get_policies(preferences=False) self.assertEqual( bytes(request), b'', ) def test_get_policies_with_audits(self): request = Policies.get_policies(audits=True) self.assertEqual( bytes(request), b'', ) request = Policies.get_policies(audits=False) self.assertEqual( bytes(request), b'', ) def test_get_policy(self): request = Policies.get_policy("policy_id") self.assertEqual( bytes(request), b'', ) def test_get_policy_with_audits(self): request = Policies.get_policy("policy_id", audits=True) self.assertEqual( bytes(request), b'', ) request = Policies.get_policy("policy_id", audits=False) self.assertEqual( bytes(request), b'', ) def test_get_policy_missing_policy_id(self): with self.assertRaises(RequiredArgument): Policies.get_policy(None) with self.assertRaises(RequiredArgument): Policies.get_policy("") def test_import_policy(self): request = Policies.import_policy(POLICY_XML_STRING) self.assertEqual( bytes(request), b"" b'' b'' b"Foobar" b"Foobar config" b"2018-11-09T10:48:03Z" b"2018-11-09T10:48:03Z" b"" b"" b"", ) def test_import_policy_missing_policy_xml(self): with self.assertRaises(RequiredArgument): Policies.import_policy(None) with self.assertRaises(RequiredArgument): Policies.import_policy("") def test_import_policy_invalid_xml(self): with self.assertRaises(InvalidArgument): Policies.import_policy("abcdef") def test_modify_policy_set_nvt_preference(self): request = Policies.modify_policy_set_nvt_preference( "policy_id", "name", "oid" ) self.assertEqual( bytes(request), b'' b"" b'' b"name" b"" b"", ) def test_modify_policy_set_nvt_preference_with_value(self): request = Policies.modify_policy_set_nvt_preference( "policy_id", "name", "oid", value="bar" ) self.assertEqual( bytes(request), b'' b"" b'' b"name" b"YmFy" b"" b"", ) def test_modify_policy_set_nvt_preference_missing_policy_id(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_preference(None, "name", "oid") with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_preference("", "name", "oid") def test_modify_policy_set_nvt_preference_missing_name(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_preference("policy_id", None, "oid") with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_preference("policy_id", "", "oid") def test_modify_policy_set_nvt_preference_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_preference("policy_id", "name", None) with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_preference("policy_id", "name", "") def test_modify_policy_set_name(self): request = Policies.modify_policy_set_name("policy_id", "name") self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_policy_set_name_missing_policy_id(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_name(None, "name") with self.assertRaises(RequiredArgument): Policies.modify_policy_set_name("", "name") def test_modify_policy_set_name_missing_name(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_name("policy_id", None) with self.assertRaises(RequiredArgument): Policies.modify_policy_set_name("policy_id", "") def test_modify_policy_set_comment(self): request = Policies.modify_policy_set_comment("policy_id", None) self.assertEqual( bytes(request), b'' b"" b"", ) request = Policies.modify_policy_set_comment("policy_id", "comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_policy_set_comment_missing_policy_id(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_comment(None, "comment") with self.assertRaises(RequiredArgument): Policies.modify_policy_set_comment("", "comment") def test_modify_policy_set_scanner_preference(self): request = Policies.modify_policy_set_scanner_preference( "policy_id", "name", ) self.assertEqual( bytes(request), b'' b"" b"name" b"" b"", ) def test_modify_policy_set_scanner_preference_with_value(self): request = Policies.modify_policy_set_scanner_preference( "policy_id", "name", value="bar", ) self.assertEqual( bytes(request), b'' b"" b"name" b"YmFy" b"" b"", ) def test_modify_policy_set_scanner_preference_missing_policy_id(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_scanner_preference(None, "name") with self.assertRaises(RequiredArgument): Policies.modify_policy_set_scanner_preference("", "name") def test_modify_policy_set_scanner_preference_missing_name(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_scanner_preference("policy_id", None) with self.assertRaises(RequiredArgument): Policies.modify_policy_set_scanner_preference("policy_id", "") def test_modify_policy_set_nvt_selection(self): request = Policies.modify_policy_set_nvt_selection( "policy_id", "name", ["oid"], ) self.assertEqual( bytes(request), b'' b"" b"name" b'' b"" b"", ) request = Policies.modify_policy_set_nvt_selection( "policy_id", "name", ["oid1", "oid2"], ) self.assertEqual( bytes(request), b'' b"" b"name" b'' b'' b"" b"", ) def test_modify_policy_set_nvt_selection_missing_policy_id(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_selection(None, "name", ["oid"]) with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_selection("", "name", ["oid"]) def test_modify_policy_set_nvt_selection_missing_family(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_selection("policy_id", None, ["oid"]) with self.assertRaises(RequiredArgument): Policies.modify_policy_set_nvt_selection("policy_id", "", ["oid"]) def test_modify_policy_set_family_selection(self): request = Policies.modify_policy_set_family_selection( "policy_id", [("name", True, True)], ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"name" b"1" b"1" b"" b"" b"", ) request = Policies.modify_policy_set_family_selection( "policy_id", [("name1", True, True), ("name2", True, False)], ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"name1" b"1" b"1" b"" b"" b"name2" b"0" b"1" b"" b"" b"", ) def test_modify_policy_set_family_selection_with_auto_add_new_families( self, ): request = Policies.modify_policy_set_family_selection( "policy_id", [("name", True, True)], auto_add_new_families=True, ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"name" b"1" b"1" b"" b"" b"", ) request = Policies.modify_policy_set_family_selection( "policy_id", [("name", True, True)], auto_add_new_families=False, ) self.assertEqual( bytes(request), b'' b"" b"0" b"" b"name" b"1" b"1" b"" b"" b"", ) def test_modify_policy_set_family_selection_missing_policy_id(self): with self.assertRaises(RequiredArgument): Policies.modify_policy_set_family_selection( None, [("name", True, True)] ) with self.assertRaises(RequiredArgument): Policies.modify_policy_set_family_selection( "", [("name", True, True)] ) def test_modify_policy_set_family_selection_invalid_families(self): with self.assertRaises(InvalidArgument): Policies.modify_policy_set_family_selection( "policy_id", [("name", True, True, True)] ) with self.assertRaises(InvalidArgument): Policies.modify_policy_set_family_selection( "policy_id", [("name", True)] ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_port_lists.py000066400000000000000000000247401466406635600261000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import PortLists, PortRangeType class PortListsTestCase(unittest.TestCase): def test_clone(self) -> None: request = PortLists.clone_port_list("a1") self.assertEqual( bytes(request), b"a1", ) def test_clone_missing_id(self): with self.assertRaises(RequiredArgument): PortLists.clone_port_list("") with self.assertRaises(RequiredArgument): PortLists.clone_port_list(None) def test_create_port_list_missing_name(self): with self.assertRaises(RequiredArgument): PortLists.create_port_list(name=None, port_range="T:1-1234") with self.assertRaises(RequiredArgument): PortLists.create_port_list(name="", port_range="T:1-1234") def test_create_port_list_missing_port_range(self): with self.assertRaises(RequiredArgument): PortLists.create_port_list(name="foo", port_range=None) with self.assertRaises(RequiredArgument): PortLists.create_port_list(name="foo", port_range="") def test_create_port_list(self): request = PortLists.create_port_list(name="foo", port_range="T:1-1234") self.assertEqual( bytes(request), b"" b"foo" b"T:1-1234" b"", ) def test_create_port_list_with_comment(self): request = PortLists.create_port_list( name="foo", port_range="T:1-1234", comment="lorem" ) self.assertEqual( bytes(request), b"" b"foo" b"T:1-1234" b"lorem" b"", ) def test_create_port_range_missing_port_list_id(self): with self.assertRaises(RequiredArgument): PortLists.create_port_range( port_list_id=None, start=1, end=1234, port_range_type=PortRangeType.TCP, ) with self.assertRaises(RequiredArgument): PortLists.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): PortLists.create_port_range( port_list_id="pl1", start=None, end=1234, port_range_type=PortRangeType.TCP, ) with self.assertRaises(RequiredArgument): PortLists.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): PortLists.create_port_range( port_list_id="pl1", start=1, end=None, port_range_type=PortRangeType.TCP, ) with self.assertRaises(RequiredArgument): PortLists.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): PortLists.create_port_range( port_list_id="pl1", start=1, end=1234, port_range_type=None ) with self.assertRaises(RequiredArgument): PortLists.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(InvalidArgument): PortLists.create_port_range( port_list_id="pl1", start=1, end=1234, port_range_type="blubb" ) def test_create_port_range(self): request = PortLists.create_port_range( port_list_id="pl1", start=1, end=1234, port_range_type=PortRangeType.TCP, ) self.assertEqual( bytes(request), b"" b'' b"1" b"1234" b"TCP" b"", ) request = PortLists.create_port_range( port_list_id="pl1", start=1, end=1234, port_range_type=PortRangeType.UDP, ) self.assertEqual( bytes(request), b"" b'' b"1" b"1234" b"UDP" b"", ) request = PortLists.create_port_range( port_list_id="pl1", start="1", end="1234", port_range_type=PortRangeType.TCP, ) self.assertEqual( bytes(request), b"" b'' b"1" b"1234" b"TCP" b"", ) def test_create_port_range_with_comment(self): request = PortLists.create_port_range( port_list_id="pl1", start=1, end=1234, port_range_type=PortRangeType.TCP, comment="lorem", ) self.assertEqual( bytes(request), b"" b'' b"1" b"1234" b"TCP" b"lorem" b"", ) def test_delete(self): request = PortLists.delete_port_list("a1") self.assertEqual( bytes(request), b'', ) def test_delete_ultimate(self): request = PortLists.delete_port_list("a1", ultimate=True) self.assertEqual( bytes(request), b'', ) def test_delete_missing_id(self): with self.assertRaises(RequiredArgument): PortLists.delete_port_list(None) with self.assertRaises(RequiredArgument): PortLists.delete_port_list("") def test_delete_port_range(self): request = PortLists.delete_port_range("a1") self.assertEqual( bytes(request), b'' ) def test_delete_port_range_missing_id(self): with self.assertRaises(RequiredArgument): PortLists.delete_port_range(None) with self.assertRaises(RequiredArgument): PortLists.delete_port_range("") def test_get_port_lists(self): request = PortLists.get_port_lists() self.assertEqual(bytes(request), b"") def test_get_port_lists_with_filter_string(self): request = PortLists.get_port_lists(filter_string="foo=bar") self.assertEqual(bytes(request), b'') def test_get_port_lists_with_filter_id(self): request = PortLists.get_port_lists(filter_id="f1") self.assertEqual(bytes(request), b'') def test_get_port_lists_with_trash(self): request = PortLists.get_port_lists(trash=True) self.assertEqual(bytes(request), b'') request = PortLists.get_port_lists(trash=False) self.assertEqual(bytes(request), b'') def test_get_port_lists_with_details(self): request = PortLists.get_port_lists(details=True) self.assertEqual(bytes(request), b'') request = PortLists.get_port_lists(details=False) self.assertEqual(bytes(request), b'') def test_get_port_lists_with_targets(self): request = PortLists.get_port_lists(targets=True) self.assertEqual(bytes(request), b'') request = PortLists.get_port_lists(targets=False) self.assertEqual(bytes(request), b'') def test_get_port_list(self): request = PortLists.get_port_list(port_list_id="port_list_id") self.assertEqual( bytes(request), b'', ) def test_get_port_list_missing_port_list_id(self): with self.assertRaises(RequiredArgument): PortLists.get_port_list(port_list_id=None) with self.assertRaises(RequiredArgument): PortLists.get_port_list(port_list_id="") with self.assertRaises(RequiredArgument): PortLists.get_port_list("") def test_modify_port_list(self): request = PortLists.modify_port_list(port_list_id="p1") self.assertEqual( bytes(request), b'' ) def test_modify_port_list_missing_port_list_id(self): with self.assertRaises(RequiredArgument): PortLists.modify_port_list(port_list_id=None) with self.assertRaises(RequiredArgument): PortLists.modify_port_list(port_list_id="") with self.assertRaises(RequiredArgument): PortLists.modify_port_list("") def test_modify_port_list_with_comment(self): request = PortLists.modify_port_list(port_list_id="p1", comment="foo") self.assertEqual( bytes(request), b'' b"foo" b"", ) def test_modify_port_list_with_name(self): request = PortLists.modify_port_list(port_list_id="p1", name="foo") self.assertEqual( bytes(request), b'' b"foo" b"", ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_report_formats.py000066400000000000000000000250121466406635600267350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import ReportFormats, ReportFormatType class ReportFormatsTestCase(unittest.TestCase): def test_clone_report_format(self): request = ReportFormats.clone_report_format("report_format_id") self.assertEqual( bytes(request), b"" b"report_format_id" b"", ) request = ReportFormats.clone_report_format(ReportFormatType.PDF) self.assertEqual( bytes(request), b"" b"c402cc3e-b531-11e1-9163-406186ea4fc5" b"", ) def test_clone_report_format_missing_report_format_id(self): with self.assertRaises(RequiredArgument): ReportFormats.clone_report_format(None) with self.assertRaises(RequiredArgument): ReportFormats.clone_report_format("") def test_delete_report_format(self): request = ReportFormats.delete_report_format("report_format_id") self.assertEqual( bytes(request), b'', ) request = ReportFormats.delete_report_format(ReportFormatType.PDF) self.assertEqual( bytes(request), b'', ) def test_delete_report_format_with_ultimate(self): request = ReportFormats.delete_report_format( "report_format_id", ultimate=True ) self.assertEqual( bytes(request), b'', ) request = ReportFormats.delete_report_format( ReportFormatType.PDF, ultimate=False ) self.assertEqual( bytes(request), b'', ) def test_delete_report_format_missing_report_format_id(self): with self.assertRaises(RequiredArgument): ReportFormats.delete_report_format(None) with self.assertRaises(RequiredArgument): ReportFormats.delete_report_format("") def test_get_report_formats(self): request = ReportFormats.get_report_formats() self.assertEqual( bytes(request), b"", ) def test_get_report_formats_with_filter_string(self): request = ReportFormats.get_report_formats( filter_string="filter_string" ) self.assertEqual( bytes(request), b'', ) def test_get_report_formats_with_filter_id(self): request = ReportFormats.get_report_formats(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_report_formats_with_details(self): request = ReportFormats.get_report_formats(details=True) self.assertEqual( bytes(request), b'', ) request = ReportFormats.get_report_formats(details=False) self.assertEqual( bytes(request), b'', ) def test_get_report_formats_with_alerts(self): request = ReportFormats.get_report_formats(alerts=True) self.assertEqual( bytes(request), b'', ) request = ReportFormats.get_report_formats(alerts=False) self.assertEqual( bytes(request), b'', ) def test_get_report_formats_with_params(self): request = ReportFormats.get_report_formats(params=True) self.assertEqual( bytes(request), b'', ) request = ReportFormats.get_report_formats(params=False) self.assertEqual( bytes(request), b'', ) def test_get_report_formats_with_trash(self): request = ReportFormats.get_report_formats(trash=True) self.assertEqual( bytes(request), b'', ) request = ReportFormats.get_report_formats(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_report_format(self): request = ReportFormats.get_report_format("report_format_id") self.assertEqual( bytes(request), b'', ) request = ReportFormats.get_report_format(ReportFormatType.PDF) self.assertEqual( bytes(request), b'', ) def test_get_report_format_missing_report_format_id(self): with self.assertRaises(RequiredArgument): ReportFormats.get_report_format(None) with self.assertRaises(RequiredArgument): ReportFormats.get_report_format("") def test_import_report_format(self): REPORT_FORMAT_XML_STRING = ( '' '' "Foobar" "Foobar report_format" "2018-11-09T10:48:03Z" "2018-11-09T10:48:03Z" "" "" ) request = ReportFormats.import_report_format(REPORT_FORMAT_XML_STRING) self.assertEqual( bytes(request), b"" b'' b'' b"Foobar" b"Foobar report_format" b"2018-11-09T10:48:03Z" b"2018-11-09T10:48:03Z" b"" b"" b"", ) def test_import_report_format_invalid_report_format(self): with self.assertRaises(InvalidArgument): ReportFormats.import_report_format("invalid_report_format") def test_modify_report_format(self): request = ReportFormats.modify_report_format("report_format_id") self.assertEqual( bytes(request), b'', ) request = ReportFormats.modify_report_format(ReportFormatType.PDF) self.assertEqual( bytes(request), b'', ) def test_modify_report_format_with_active(self): request = ReportFormats.modify_report_format( "report_format_id", active=True ) self.assertEqual( bytes(request), b'' b"1" b"", ) request = ReportFormats.modify_report_format( ReportFormatType.PDF, active=False ) self.assertEqual( bytes(request), b'' b"0" b"", ) def test_modify_report_format_with_name(self): request = ReportFormats.modify_report_format( "report_format_id", name="Foobar" ) self.assertEqual( bytes(request), b'' b"Foobar" b"", ) def test_modify_report_format_with_summary(self): request = ReportFormats.modify_report_format( "report_format_id", summary="Foobar report_format" ) self.assertEqual( bytes(request), b'' b"Foobar report_format" b"", ) def test_modify_report_format_with_param_name(self): request = ReportFormats.modify_report_format( "report_format_id", param_name="Foobar" ) self.assertEqual( bytes(request), b'' b"" b"Foobar" b"" b"", ) def test_modify_report_format_with_param_name_and_value(self): request = ReportFormats.modify_report_format( "report_format_id", param_name="Foobar", param_value="42" ) self.assertEqual( bytes(request), b'' b"" b"Foobar" b"42" b"" b"", ) def test_verify_report_format(self): request = ReportFormats.verify_report_format("report_format_id") self.assertEqual( bytes(request), b'', ) request = ReportFormats.verify_report_format(ReportFormatType.PDF) self.assertEqual( bytes(request), b'', ) def test_verify_report_format_missing_report_format_id(self): with self.assertRaises(RequiredArgument): ReportFormats.verify_report_format(None) with self.assertRaises(RequiredArgument): ReportFormats.verify_report_format("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_reports.py000066400000000000000000000167561466406635600254040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Reports REPORT_XML_STRING = ( '' '' '' "0.0" '' "132.67.253.114" "" ) class ReportsTestCase(unittest.TestCase): def test_delete_report(self): request = Reports.delete_report("report_id") self.assertEqual( bytes(request), b'', ) def test_delete_report_missing_report_id(self): with self.assertRaises(RequiredArgument): Reports.delete_report(None) with self.assertRaises(RequiredArgument): Reports.delete_report("") def test_get_report(self): request = Reports.get_report("report_id") self.assertEqual( bytes(request), b'', ) def test_get_report_with_filter_string(self): request = Reports.get_report("report_id", filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_report_with_filter_id(self): request = Reports.get_report("report_id", filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_report_with_delta_report_id(self): request = Reports.get_report( "report_id", delta_report_id="delta_report_id" ) self.assertEqual( bytes(request), b'', ) def test_get_report_with_report_format_id(self): request = Reports.get_report( "report_id", report_format_id="report_format_id" ) self.assertEqual( bytes(request), b'', ) def test_get_report_with_ignore_pagination(self): request = Reports.get_report("report_id", ignore_pagination=True) self.assertEqual( bytes(request), b'', ) def test_get_report_missing_report_id(self): with self.assertRaises(RequiredArgument): Reports.get_report(None) with self.assertRaises(RequiredArgument): Reports.get_report("") def test_get_reports(self): request = Reports.get_reports() self.assertEqual( bytes(request), b"", ) def test_get_reports_with_filter_string(self): request = Reports.get_reports(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_reports_with_filter_id(self): request = Reports.get_reports(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_reports_with_note_details(self): request = Reports.get_reports(note_details=True) self.assertEqual( bytes(request), b'', ) request = Reports.get_reports(note_details=False) self.assertEqual( bytes(request), b'', ) def test_get_reports_with_override_details(self): request = Reports.get_reports(override_details=True) self.assertEqual( bytes(request), b'', ) request = Reports.get_reports(override_details=False) self.assertEqual( bytes(request), b'', ) def test_get_reports_with_details(self): request = Reports.get_reports(details=True) self.assertEqual( bytes(request), b'', ) request = Reports.get_reports(details=False) self.assertEqual( bytes(request), b'', ) def test_get_reports_with_ignore_pagination(self): request = Reports.get_reports(ignore_pagination=True) self.assertEqual( bytes(request), b'', ) request = Reports.get_reports(ignore_pagination=False) self.assertEqual( bytes(request), b'', ) def test_import_report(self): request = Reports.import_report(REPORT_XML_STRING, "task_id") self.assertEqual( bytes(request), b"" b'' b'' b'' b'' b"0.0" b'' b"132.67.253.114" b"" b"", ) def test_import_report_with_in_assets(self): request = Reports.import_report( REPORT_XML_STRING, "task_id", in_assets=False ) self.assertEqual( bytes(request), b"" b'' b"0" b'' b'' b'' b"0.0" b'' b"132.67.253.114" b"" b"", ) request = Reports.import_report( REPORT_XML_STRING, "task_id", in_assets=True ) self.assertEqual( bytes(request), b"" b'' b"1" b'' b'' b'' b"0.0" b'' b"132.67.253.114" b"" b"", ) def test_import_report_missing_report(self): with self.assertRaises(RequiredArgument): Reports.import_report(None, "task_id") with self.assertRaises(RequiredArgument): Reports.import_report("", "task_id") def test_import_report_missing_task_id(self): with self.assertRaises(RequiredArgument): Reports.import_report("report", None) with self.assertRaises(RequiredArgument): Reports.import_report("report", "") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_results.py000066400000000000000000000052041466406635600253710ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Results class ResultsTestCase(unittest.TestCase): def test_get_result(self): request = Results.get_result("result_id") self.assertEqual( bytes(request), b'', ) def test_get_result_missing_result_id(self): with self.assertRaises(RequiredArgument): Results.get_result(None) with self.assertRaises(RequiredArgument): Results.get_result("") def test_get_results(self): request = Results.get_results() self.assertEqual( bytes(request), b"", ) def test_get_results_with_filter_string(self): request = Results.get_results(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_results_with_filter_id(self): request = Results.get_results(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_results_with_task_id(self): request = Results.get_results(task_id="task_id") self.assertEqual( bytes(request), b'', ) def test_get_results_with_note_details(self): request = Results.get_results(note_details=True) self.assertEqual( bytes(request), b'', ) request = Results.get_results(note_details=False) self.assertEqual( bytes(request), b'', ) def test_get_results_with_override_details(self): request = Results.get_results(override_details=True) self.assertEqual( bytes(request), b'', ) request = Results.get_results(override_details=False) self.assertEqual( bytes(request), b'', ) def test_get_results_with_details(self): request = Results.get_results(details=True) self.assertEqual( bytes(request), b'', ) request = Results.get_results(details=False) self.assertEqual( bytes(request), b'', ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_roles.py000066400000000000000000000103571466406635600250210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Roles class RolesTestCase(unittest.TestCase): def test_clone_role(self): request = Roles.clone_role("role_id") self.assertEqual( bytes(request), b"role_id", ) def test_clone_role_missing_role_id(self): with self.assertRaises(RequiredArgument): Roles.clone_role(None) with self.assertRaises(RequiredArgument): Roles.clone_role("") def test_create_role(self): request = Roles.create_role("name") self.assertEqual( bytes(request), b"name", ) def test_create_role_with_comment(self): request = Roles.create_role("name", comment="comment") self.assertEqual( bytes(request), b"" b"name" b"comment" b"", ) def test_create_role_with_users(self): request = Roles.create_role("name", users=["user1", "user2"]) self.assertEqual( bytes(request), b"" b"name" b"user1,user2" b"", ) def test_create_role_missing_name(self): with self.assertRaises(RequiredArgument): Roles.create_role(None) with self.assertRaises(RequiredArgument): Roles.create_role("") def test_get_roles(self): request = Roles.get_roles() self.assertEqual( bytes(request), b"", ) def test_get_roles_with_filter_string(self): request = Roles.get_roles(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_roles_with_filter_id(self): request = Roles.get_roles(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_roles_with_trash(self): request = Roles.get_roles(trash=True) self.assertEqual( bytes(request), b'', ) request = Roles.get_roles(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_role(self): request = Roles.get_role("role_id") self.assertEqual( bytes(request), b'', ) def test_get_role_missing_role_id(self): with self.assertRaises(RequiredArgument): Roles.get_role(None) with self.assertRaises(RequiredArgument): Roles.get_role("") def test_modify_role(self): request = Roles.modify_role("role_id") self.assertEqual( bytes(request), b'', ) def test_modify_role_with_comment(self): request = Roles.modify_role("role_id", comment="comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_role_with_name(self): request = Roles.modify_role("role_id", name="name") self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_role_with_users(self): request = Roles.modify_role("role_id", users=["user1", "user2"]) self.assertEqual( bytes(request), b'' b"user1,user2" b"", ) def test_modify_role_missing_role_id(self): with self.assertRaises(RequiredArgument): Roles.modify_role(None) with self.assertRaises(RequiredArgument): Roles.modify_role("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_scan_configs.py000066400000000000000000000615401466406635600263310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.protocols.gmp.requests.v224 import ScanConfigs class ScanConfigsTestCase(unittest.TestCase): def test_clone_scan_config(self): request = ScanConfigs.clone_scan_config("a1") self.assertEqual( bytes(request), b"a1" ) def test_clone_scan_config_missing_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.clone_scan_config("") with self.assertRaises(RequiredArgument): ScanConfigs.clone_scan_config(None) def test_create_scan_config(self): request = ScanConfigs.create_scan_config("a1", "foo") self.assertEqual( bytes(request), b"a1foo" b"scan", ) def test_create_scan_config_with_comment(self): request = ScanConfigs.create_scan_config("a1", "foo", comment="comment") self.assertEqual( bytes(request), b"commenta1" b"fooscan", ) def test_create_scan_config_missing_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.create_scan_config("", "foo") with self.assertRaises(RequiredArgument): ScanConfigs.create_scan_config(None, "foo") def test_create_scan_config_missing_name(self): with self.assertRaises(RequiredArgument): ScanConfigs.create_scan_config("c1", None) with self.assertRaises(RequiredArgument): ScanConfigs.create_scan_config("c1", "") def test_delete_scan_config(self): request = ScanConfigs.delete_scan_config("a1") self.assertEqual( bytes(request), b'' ) def test_delete_scan_config_ultimate(self): request = ScanConfigs.delete_scan_config("a1", ultimate=True) self.assertEqual( bytes(request), b'' ) def test_delete_scan_config_missing_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.delete_scan_config("") with self.assertRaises(RequiredArgument): ScanConfigs.delete_scan_config(None) def test_get_scan_config_preference(self): request = ScanConfigs.get_scan_config_preference("foo") self.assertEqual(bytes(request), b'') def test_get_scan_config_preference_missing_name(self): with self.assertRaises(RequiredArgument): ScanConfigs.get_scan_config_preference("") with self.assertRaises(RequiredArgument): ScanConfigs.get_scan_config_preference(None) def test_get_scan_config_preference_with_nvt_oid(self): request = ScanConfigs.get_scan_config_preference("foo", nvt_oid="oid") self.assertEqual( bytes(request), b'' ) def test_get_scan_config_preference_with_config_id(self): request = ScanConfigs.get_scan_config_preference("foo", config_id="c1") self.assertEqual( bytes(request), b'', ) def test_get_scan_config_preferences(self): request = ScanConfigs.get_scan_config_preferences() self.assertEqual(bytes(request), b"") def test_get_scan_config_preferences_with_nvt_oid(self): request = ScanConfigs.get_scan_config_preferences(nvt_oid="oid") self.assertEqual(bytes(request), b'') def test_get_scan_config_preferences_with_config_id(self): request = ScanConfigs.get_scan_config_preferences(config_id="c1") self.assertEqual(bytes(request), b'') def test_get_scan_config(self): request = ScanConfigs.get_scan_config("a1") self.assertEqual( bytes(request), b'', ) def test_get_scan_config_with_tasks(self): request = ScanConfigs.get_scan_config("a1", tasks=True) self.assertEqual( bytes(request), b'', ) def test_get_scan_config_without_scan_config_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.get_scan_config(None) with self.assertRaises(RequiredArgument): ScanConfigs.get_scan_config("") def test_get_scan_configs(self): request = ScanConfigs.get_scan_configs() self.assertEqual(bytes(request), b'') def test_get_scan_configs_with_filter_string(self): request = ScanConfigs.get_scan_configs(filter_string="name=foo") self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_with_filter_id(self): request = ScanConfigs.get_scan_configs(filter_id="f1") self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_from_trash(self): request = ScanConfigs.get_scan_configs(trash=True) self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_with_details(self): request = ScanConfigs.get_scan_configs(details=True) self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_without_details(self): request = ScanConfigs.get_scan_configs(details=False) self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_with_families(self): request = ScanConfigs.get_scan_configs(families=True) self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_without_families(self): request = ScanConfigs.get_scan_configs(families=False) self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_with_preferences(self): request = ScanConfigs.get_scan_configs(preferences=True) self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_without_preferences(self): request = ScanConfigs.get_scan_configs(preferences=False) self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_with_tasks(self): request = ScanConfigs.get_scan_configs(tasks=True) self.assertEqual( bytes(request), b'', ) def test_get_scan_configs_without_tasks(self): request = ScanConfigs.get_scan_configs(tasks=False) self.assertEqual( bytes(request), b'', ) def test_import_scan_config(self): CONFIG_XML_STRING = ( '' '' "Foobar" "Foobar config" "2018-11-09T10:48:03Z" "2018-11-09T10:48:03Z" "" "" ) request = ScanConfigs.import_scan_config(CONFIG_XML_STRING) self.assertEqual( bytes(request), f"{CONFIG_XML_STRING}".encode( encoding="utf-8" ), ) def test_import_missing_scan_config_xml(self): with self.assertRaises(RequiredArgument): ScanConfigs.import_scan_config(None) with self.assertRaises(RequiredArgument): ScanConfigs.import_scan_config("") def test_import_invalid_xml(self): with self.assertRaises(InvalidArgument): ScanConfigs.import_scan_config("abcdef") def test_modify_scan_config_set_comment(self): request = ScanConfigs.modify_scan_config_set_comment("c1") self.assertEqual( bytes(request), b'', ) request = ScanConfigs.modify_scan_config_set_comment( "c1", comment="foo" ) self.assertEqual( bytes(request), b'foo', ) request = ScanConfigs.modify_scan_config_set_comment("c1", comment=None) self.assertEqual( bytes(request), b'', ) def test_modify_scan_config_set_comment_missing_config_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_comment(config_id=None) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_comment("") with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_comment(config_id="") def test_modify_scan_config_set_family_selection(self): request = ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", True, True)] ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"", ) request = ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", True, True), ("bar", True, True)] ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"bar" b"1" b"1" b"" b"" b"", ) request = ScanConfigs.modify_scan_config_set_family_selection( "c1", (("foo", True, True), ("bar", True, True)) ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"bar" b"1" b"1" b"" b"" b"", ) request = ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", True, False), ("bar", False, True)] ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"foo" b"0" b"1" b"" b"" b"bar" b"1" b"0" b"" b"" b"", ) def test_modify_scan_config_set_family_selection_missing_config_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_family_selection( None, [("foo", True, True)] ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_family_selection( "", [("foo", True, True)] ) def test_modify_scan_config_set_family_selection_invalid_families(self): with self.assertRaises(InvalidArgumentType): ScanConfigs.modify_scan_config_set_family_selection( "c1", None, ) with self.assertRaises(InvalidArgumentType): ScanConfigs.modify_scan_config_set_family_selection( "c1", "", ) def test_modify_scan_config_set_family_selection_with_auto_add_new_families( self, ): request = ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", True, True)], auto_add_new_families=True ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"", ) request = ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", True, True)], auto_add_new_families=False ) self.assertEqual( bytes(request), b'' b"" b"0" b"" b"foo" b"1" b"1" b"" b"" b"", ) def test_modify_scan_config_set_family_selection_with_auto_add_new_nvts( self, ): request = ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", True, True)] ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"", ) request = ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", False, True)] ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"foo" b"1" b"0" b"" b"" b"", ) request = ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", False, True), ("bar", True, False)], ) self.assertEqual( bytes(request), b'' b"" b"1" b"" b"foo" b"1" b"0" b"" b"" b"bar" b"0" b"1" b"" b"" b"", ) def test_modify_scan_config_set_family_selection_with_invalid_arguments( self, ): with self.assertRaises(InvalidArgumentType): ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", "False", "True")] ) with self.assertRaises(InvalidArgumentType): ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", True, None)] ) with self.assertRaises(InvalidArgumentType): ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo", "True", False)] ) with self.assertRaises(InvalidArgument): ScanConfigs.modify_scan_config_set_family_selection( "c1", [("foo",)] ) def test_modify_scan_config_set_name(self): request = ScanConfigs.modify_scan_config_set_name("c1", "foo") self.assertEqual( bytes(request), b'foo', ) def test_modify_scan_config_set_name_missing_config_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_name(None, name="name") with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_name("", name="name") with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_name(config_id="", name="name") def test_modify_scan_config_set_name_missing_name(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_name("c1", None) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_name("c1", "") def test_modify_scan_config_set_nvt_preference(self): request = ScanConfigs.modify_scan_config_set_nvt_preference( "c1", nvt_oid="o1", name="foo" ) self.assertEqual( bytes(request), b'' b"" b'' b"foo" b"" b"", ) request = ScanConfigs.modify_scan_config_set_nvt_preference( "c1", "foo", "o1" ) self.assertEqual( bytes(request), b'' b"" b'' b"foo" b"" b"", ) def test_modify_scan_config_set_nvt_pref_with_value(self): request = ScanConfigs.modify_scan_config_set_nvt_preference( "c1", "foo", nvt_oid="o1", value="bar" ) self.assertEqual( bytes(request), b'' b"" b'' b"foo" b"YmFy" b"" b"", ) def test_modify_scan_config_set_nvt_pref_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_preference( "c1", "foo", nvt_oid=None, value="bar" ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_preference( "c1", "foo", nvt_oid="", value="bar" ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_preference( "c1", "foo", "", value="bar" ) def test_modify_scan_config_nvt_pref_missing_name(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_preference( "c1", name=None, nvt_oid="o1", value="bar" ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_preference( "c1", name="", nvt_oid="o1", value="bar" ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_preference( "c1", "", nvt_oid="o1", value="bar" ) def test_modify_scan_config_set_nvt_preference_missing_config_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_preference("", "foo", "o1") with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_preference(None, "foo", "o1") def test_modify_scan_config_set_nvt_selection(self): request = ScanConfigs.modify_scan_config_set_nvt_selection( "c1", "foo", ["o1"] ) self.assertEqual( bytes(request), b'' b"" b"foo" b'' b"" b"", ) request = ScanConfigs.modify_scan_config_set_nvt_selection( "c1", "foo", ["o1", "o2"] ) self.assertEqual( bytes(request), b'' b"" b"foo" b'' b'' b"" b"", ) request = ScanConfigs.modify_scan_config_set_nvt_selection( "c1", "foo", ("o1", "o2") ) self.assertEqual( bytes(request), b'' b"" b"foo" b'' b'' b"" b"", ) request = ScanConfigs.modify_scan_config_set_nvt_selection( "c1", "foo", [] ) self.assertEqual( bytes(request), b'' b"" b"foo" b"" b"", ) def test_modify_scan_config_set_nvt_selection_missing_config_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_selection( None, "foo", ["o1"] ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_nvt_selection("", "foo", ["o1"]) def test_modify_scan_config_set_nvt_selection_invalid_nvt_oids(self): with self.assertRaises(InvalidArgumentType): ScanConfigs.modify_scan_config_set_nvt_selection("c1", "foo", None) with self.assertRaises(InvalidArgumentType): ScanConfigs.modify_scan_config_set_nvt_selection("c1", "foo", "") def test_modify_scan_config_set_scanner_pref(self): request = ScanConfigs.modify_scan_config_set_scanner_preference( "c1", "foo" ) self.assertEqual( bytes(request), b'' b"" b"foo" b"" b"", ) def test_modify_scan_config_set_scanner_pref_with_value(self): request = ScanConfigs.modify_scan_config_set_scanner_preference( "c1", "foo", value="bar" ) self.assertEqual( bytes(request), b'' b"" b"foo" b"YmFy" b"" b"", ) def test_modify_scan_config_scanner_pref_missing_name(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_scanner_preference( "c1", name=None, value="bar" ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_scanner_preference( "c1", name="", value="bar" ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_scanner_preference( "c1", "", value="bar" ) def test_modify_scan_config_set_scanner_pref_missing_config_id(self): with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_scanner_preference( None, name="foo" ) with self.assertRaises(RequiredArgument): ScanConfigs.modify_scan_config_set_scanner_preference( "", name="foo" ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_scanners.py000066400000000000000000000276631466406635600255210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Scanners, ScannerType class ScannersTestCase(unittest.TestCase): def test_create_scanner(self): request = Scanners.create_scanner( "foo", "localhost", 1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", ) self.assertEqual( bytes(request), b"" b"foo" b"localhost" b"1234" b"2" b'' b"", ) def test_create_scanner_missing_name(self): with self.assertRaises(RequiredArgument): Scanners.create_scanner( None, "localhost", 1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", ) with self.assertRaises(RequiredArgument): Scanners.create_scanner( "", "localhost", 1234, scanner_type="2", credential_id="c1", ) def test_create_scanner_missing_host(self): with self.assertRaises(RequiredArgument): Scanners.create_scanner( "foo", None, 1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", ) with self.assertRaises(RequiredArgument): Scanners.create_scanner( "foo", "", 1234, scanner_type="2", credential_id="c1", ) def test_create_scanner_missing_port(self): with self.assertRaises(RequiredArgument): Scanners.create_scanner( "foo", "localhost", None, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", ) with self.assertRaises(RequiredArgument): Scanners.create_scanner( "foo", "localhost", "", scanner_type="2", credential_id="c1", ) def test_create_scanner_missing_scanner_type(self): with self.assertRaises(RequiredArgument): Scanners.create_scanner( "foo", "localhost", 1234, scanner_type=None, credential_id="c1", ) with self.assertRaises(RequiredArgument): Scanners.create_scanner( "foo", "localhost", 1234, scanner_type="", credential_id="c1", ) def test_create_scanner_missing_credential_id(self): with self.assertRaises(RequiredArgument): Scanners.create_scanner( "foo", "localhost", 1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id=None, ) with self.assertRaises(RequiredArgument): Scanners.create_scanner( "foo", "localhost", 1234, scanner_type="2", credential_id="", ) def test_create_scanner_invalid_scanner_type(self): with self.assertRaises(InvalidArgument): Scanners.create_scanner( "foo", "localhost", 1234, scanner_type="invalid", credential_id="c1", ) def test_create_scanner_with_ca_pub(self): request = Scanners.create_scanner( "foo", "localhost", 1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", ca_pub="foo", ) self.assertEqual( bytes(request), b"" b"foo" b"localhost" b"1234" b"2" b'' b"foo" b"", ) def test_create_scanner_with_comment(self): request = Scanners.create_scanner( "foo", "localhost", 1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", comment="foo", ) self.assertEqual( bytes(request), b"" b"foo" b"localhost" b"1234" b"2" b'' b"foo" b"", ) def test_modify_scanner(self): request = Scanners.modify_scanner("s1") self.assertEqual( bytes(request), b'', ) def test_modify_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): Scanners.modify_scanner(None) with self.assertRaises(RequiredArgument): Scanners.modify_scanner("") def test_modify_scanner_with_comment(self): request = Scanners.modify_scanner("s1", comment="foo") self.assertEqual( bytes(request), b'' b"foo" b"", ) def test_modify_scanner_with_host(self): request = Scanners.modify_scanner("s1", host="foo") self.assertEqual( bytes(request), b'' b"foo" b"", ) def test_modify_scanner_with_port(self): request = Scanners.modify_scanner("s1", port=1234) self.assertEqual( bytes(request), b'' b"1234" b"", ) request = Scanners.modify_scanner("s1", port="1234") self.assertEqual( bytes(request), b'' b"1234" b"", ) def test_modify_scanner_with_name(self): request = Scanners.modify_scanner("s1", name="foo") self.assertEqual( bytes(request), b'' b"foo" b"", ) def test_modify_scanner_with_ca_pub(self): request = Scanners.modify_scanner("s1", ca_pub="foo") self.assertEqual( bytes(request), b'' b"foo" b"", ) def test_modify_scanner_with_credential_id(self): request = Scanners.modify_scanner("s1", credential_id="c1") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_scanner_with_scanner_type(self): request = Scanners.modify_scanner( "s1", scanner_type=ScannerType.OPENVAS_SCANNER_TYPE ) self.assertEqual( bytes(request), b'' b"2" b"", ) request = Scanners.modify_scanner("s1", scanner_type="2") self.assertEqual( bytes(request), b'' b"2" b"", ) def test_modify_scanner_invalid_scanner_type(self): with self.assertRaises(InvalidArgument): Scanners.modify_scanner("s1", scanner_type="invalid") with self.assertRaises(ValueError): Scanners.modify_scanner("s1", scanner_type="") with self.assertRaises(InvalidArgument): Scanners.modify_scanner("s1", scanner_type="-1") with self.assertRaises(InvalidArgument): Scanners.modify_scanner("s1", scanner_type=1) def test_get_scanners(self): request = Scanners.get_scanners() self.assertEqual(bytes(request), b"") def test_get_scanners_with_filter_string(self): request = Scanners.get_scanners(filter_string="foo=bar") self.assertEqual( bytes(request), b'', ) def test_get_scanners_with_filter_id(self): request = Scanners.get_scanners(filter_id="f1") self.assertEqual( bytes(request), b'', ) def test_get_scanners_with_trash(self): request = Scanners.get_scanners(trash=True) self.assertEqual( bytes(request), b'', ) request = Scanners.get_scanners(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_scanners_with_details(self): request = Scanners.get_scanners(details=True) self.assertEqual( bytes(request), b'', ) request = Scanners.get_scanners(details=False) self.assertEqual( bytes(request), b'', ) def test_get_scanner(self): request = Scanners.get_scanner("s1") self.assertEqual( bytes(request), b'', ) def test_get_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): Scanners.get_scanner(None) with self.assertRaises(RequiredArgument): Scanners.get_scanner("") def test_verify_scanner(self): request = Scanners.verify_scanner("s1") self.assertEqual( bytes(request), b'', ) def test_verify_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): Scanners.verify_scanner(None) with self.assertRaises(RequiredArgument): Scanners.verify_scanner("") def test_clone_scanner(self): request = Scanners.clone_scanner("s1") self.assertEqual( bytes(request), b"s1", ) def test_clone_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): Scanners.clone_scanner(None) with self.assertRaises(RequiredArgument): Scanners.clone_scanner("") def test_delete_scanner(self): request = Scanners.delete_scanner("s1") self.assertEqual( bytes(request), b'', ) def test_delete_scanner_ultimate(self): request = Scanners.delete_scanner("s1", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Scanners.delete_scanner("s1", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_scanner_missing_scanner_id(self): with self.assertRaises(RequiredArgument): Scanners.delete_scanner(None) with self.assertRaises(RequiredArgument): Scanners.delete_scanner("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_schedules.py000066400000000000000000000163641466406635600256600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Schedules class SchedulesTestUnit(unittest.TestCase): def test_clone_schedule(self): request = Schedules.clone_schedule("schedule_id") self.assertEqual( bytes(request), b"schedule_id", ) def test_clone_schedule_missing_schedule_id(self): with self.assertRaises(RequiredArgument): Schedules.clone_schedule(None) with self.assertRaises(RequiredArgument): Schedules.clone_schedule("") def test_create_schedule(self): request = Schedules.create_schedule("name", "icalendar", "timezone") self.assertEqual( bytes(request), b"" b"name" b"icalendar" b"timezone" b"", ) def test_create_schedule_with_comment(self): request = Schedules.create_schedule( "name", "icalendar", "timezone", comment="comment" ) self.assertEqual( bytes(request), b"" b"name" b"icalendar" b"timezone" b"comment" b"", ) def test_create_schedule_missing_name(self): with self.assertRaises(RequiredArgument): Schedules.create_schedule(None, "icalendar", "timezone") with self.assertRaises(RequiredArgument): Schedules.create_schedule("", "icalendar", "timezone") def test_create_schedule_missing_icalendar(self): with self.assertRaises(RequiredArgument): Schedules.create_schedule("name", None, "timezone") with self.assertRaises(RequiredArgument): Schedules.create_schedule("name", "", "timezone") def test_create_schedule_missing_timezone(self): with self.assertRaises(RequiredArgument): Schedules.create_schedule("name", "icalendar", None) with self.assertRaises(RequiredArgument): Schedules.create_schedule("name", "icalendar", "") def test_delete_schedule(self): request = Schedules.delete_schedule("schedule_id") self.assertEqual( bytes(request), b'', ) def test_delete_schedule_with_ultimate(self): request = Schedules.delete_schedule("schedule_id", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Schedules.delete_schedule("schedule_id", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_schedule_missing_schedule_id(self): with self.assertRaises(RequiredArgument): Schedules.delete_schedule(None) with self.assertRaises(RequiredArgument): Schedules.delete_schedule("") def test_get_schedules(self): request = Schedules.get_schedules() self.assertEqual(bytes(request), b"") def test_get_schedules_with_filter_string(self): request = Schedules.get_schedules(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_schedules_with_filter_id(self): request = Schedules.get_schedules(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_schedules_with_trash(self): request = Schedules.get_schedules(trash=True) self.assertEqual( bytes(request), b'', ) request = Schedules.get_schedules(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_schedules_with_tasks(self): request = Schedules.get_schedules(tasks=True) self.assertEqual( bytes(request), b'', ) request = Schedules.get_schedules(tasks=False) self.assertEqual( bytes(request), b'', ) def test_get_schedule(self): request = Schedules.get_schedule("schedule_id") self.assertEqual( bytes(request), b'', ) def test_get_schedule_with_tasks(self): request = Schedules.get_schedule("schedule_id", tasks=True) self.assertEqual( bytes(request), b'', ) request = Schedules.get_schedule("schedule_id", tasks=False) self.assertEqual( bytes(request), b'', ) def test_get_schedule_missing_schedule_id(self): with self.assertRaises(RequiredArgument): Schedules.get_schedule(None) with self.assertRaises(RequiredArgument): Schedules.get_schedule("") def test_modify_schedule(self): request = Schedules.modify_schedule("schedule_id") self.assertEqual( bytes(request), b'' ) def test_modify_schedule_with_name(self): request = Schedules.modify_schedule("schedule_id", name="name") self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_schedule_with_comment(self): request = Schedules.modify_schedule("schedule_id", comment="comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_schedule_with_icalendar(self): request = Schedules.modify_schedule( "schedule_id", icalendar="icalendar" ) self.assertEqual( bytes(request), b'' b"icalendar" b"", ) def test_modify_schedule_with_timezone(self): request = Schedules.modify_schedule("schedule_id", timezone="timezone") self.assertEqual( bytes(request), b'' b"timezone" b"", ) def test_modify_schedule_missing_schedule_id(self): with self.assertRaises(RequiredArgument): Schedules.modify_schedule(None) with self.assertRaises(RequiredArgument): Schedules.modify_schedule("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_secinfo.py000066400000000000000000000053331466406635600253210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import SecInfo class SecInfoTestCase(unittest.TestCase): def test_get_info(self): request = SecInfo.get_info("info_id", "NVT") self.assertEqual( bytes(request), b'', ) def test_get_info_missing_info_id(self): with self.assertRaises(RequiredArgument): SecInfo.get_info(None, "NVT") with self.assertRaises(RequiredArgument): SecInfo.get_info("", "NVT") def test_get_info_missing_info_type(self): with self.assertRaises(RequiredArgument): SecInfo.get_info("info_id", None) with self.assertRaises(RequiredArgument): SecInfo.get_info("info_id", "") def test_get_info_invalid_info_type(self): with self.assertRaises(InvalidArgument): SecInfo.get_info("info_id", "invalid") def test_get_info_list(self): request = SecInfo.get_info_list("nvt") self.assertEqual( bytes(request), b'', ) def test_get_info_list_with_details(self): request = SecInfo.get_info_list("nvt", details=True) self.assertEqual( bytes(request), b'', ) request = SecInfo.get_info_list("nvt", details=False) self.assertEqual( bytes(request), b'', ) def test_get_info_list_with_filter_string(self): request = SecInfo.get_info_list("nvt", filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_info_list_with_filter_id(self): request = SecInfo.get_info_list("nvt", filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_info_list_with_name(self): request = SecInfo.get_info_list("nvt", name="name") self.assertEqual( bytes(request), b'', ) def test_get_info_list_missing_info_type(self): with self.assertRaises(RequiredArgument): SecInfo.get_info_list(None) with self.assertRaises(RequiredArgument): SecInfo.get_info_list("") def test_get_info_list_invalid_info_type(self): with self.assertRaises(InvalidArgument): SecInfo.get_info_list("invalid") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_system_report.py000066400000000000000000000037151466406635600266140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 import SystemReports class SystemReportsTestCase(unittest.TestCase): def test_get_system_reports(self): request = SystemReports.get_system_reports() self.assertEqual(bytes(request), b"") def test_system_reports_with_name(self): request = SystemReports.get_system_reports(name="foo") self.assertEqual(bytes(request), b'') def test_system_reports_with_slave_id(self): request = SystemReports.get_system_reports(slave_id="s1") self.assertEqual(bytes(request), b'') def test_system_reports_with_brief(self): request = SystemReports.get_system_reports(brief=True) self.assertEqual(bytes(request), b'') request = SystemReports.get_system_reports(brief=False) self.assertEqual(bytes(request), b'') def test_system_reports_with_duration(self): request = SystemReports.get_system_reports(duration=3600) self.assertEqual( bytes(request), b'' ) def test_system_reports_with_invalid_duration(self): with self.assertRaises(InvalidArgument): SystemReports.get_system_reports(duration="") def test_system_reports_with_start_time(self): request = SystemReports.get_system_reports(start_time="01-01-2019") self.assertEqual( bytes(request), b'' ) def test_system_reports_with_end_time(self): request = SystemReports.get_system_reports(end_time="01-01-2019") self.assertEqual( bytes(request), b'' ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_tags.py000066400000000000000000000250501466406635600246270ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Tags class TagsTestCase(unittest.TestCase): def test_clone_tag(self): request = Tags.clone_tag("tag_id") self.assertEqual( bytes(request), b"tag_id", ) def test_clone_tag_missing_tag_id(self): with self.assertRaises(RequiredArgument): Tags.clone_tag(None) with self.assertRaises(RequiredArgument): Tags.clone_tag("") def test_create_tag(self): request = Tags.create_tag("name", "alert") self.assertEqual( bytes(request), b"" b"name" b"" b"alert" b"" b"", ) def test_create_tag_with_resource_filter(self): request = Tags.create_tag("name", "alert", resource_filter="filter") self.assertEqual( bytes(request), b"" b"name" b'' b"alert" b"" b"", ) def test_create_tag_with_resource_ids(self): request = Tags.create_tag("name", "alert", resource_ids=["id1", "id2"]) self.assertEqual( bytes(request), b"" b"name" b"" b'' b'' b"alert" b"" b"", ) def test_create_tag_with_value(self): request = Tags.create_tag("name", "alert", value="value") self.assertEqual( bytes(request), b"" b"name" b"" b"alert" b"" b"value" b"", ) def test_create_tag_with_comment(self): request = Tags.create_tag("name", "alert", comment="comment") self.assertEqual( bytes(request), b"" b"name" b"" b"alert" b"" b"comment" b"", ) def test_create_tag_with_active(self): request = Tags.create_tag("name", "alert", active=True) self.assertEqual( bytes(request), b"" b"name" b"" b"alert" b"" b"1" b"", ) request = Tags.create_tag("name", "alert", active=False) self.assertEqual( bytes(request), b"" b"name" b"" b"alert" b"" b"0" b"", ) def test_create_tag_missing_name(self): with self.assertRaises(RequiredArgument): Tags.create_tag(None, "alert") with self.assertRaises(RequiredArgument): Tags.create_tag("", "alert") def test_create_tag_missing_resource_type(self): with self.assertRaises(RequiredArgument): Tags.create_tag("name", None) with self.assertRaises(RequiredArgument): Tags.create_tag("name", "") def test_create_tag_invalid_resource_type(self): with self.assertRaises(InvalidArgument): Tags.create_tag("name", "invalid") def test_create_tag_invalid_resource_filter_and_resource_ids(self): with self.assertRaises(InvalidArgument): Tags.create_tag( "name", "alert", resource_filter="filter", resource_ids=["id1", "id2"], ) def test_delete_tag(self): request = Tags.delete_tag("tag_id") self.assertEqual( bytes(request), b'', ) def test_delete_tag_with_ultimate(self): request = Tags.delete_tag("tag_id", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Tags.delete_tag("tag_id", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_get_tags(self): request = Tags.get_tags() self.assertEqual( bytes(request), b"", ) def test_get_tags_with_filter_string(self): request = Tags.get_tags(filter_string="filter") self.assertEqual( bytes(request), b'', ) def test_get_tags_with_filter_id(self): request = Tags.get_tags(filter_id="filter") self.assertEqual( bytes(request), b'', ) def test_get_tags_with_trash(self): request = Tags.get_tags(trash=True) self.assertEqual( bytes(request), b'', ) request = Tags.get_tags(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_tags_with_names_only(self): request = Tags.get_tags(names_only=True) self.assertEqual( bytes(request), b'', ) request = Tags.get_tags(names_only=False) self.assertEqual( bytes(request), b'', ) def test_get_tag(self): request = Tags.get_tag("tag_id") self.assertEqual( bytes(request), b'', ) def test_get_tag_missing_tag_id(self): with self.assertRaises(RequiredArgument): Tags.get_tag(None) with self.assertRaises(RequiredArgument): Tags.get_tag("") def test_modify_tag(self): request = Tags.modify_tag("tag_id", resource_type="alert") self.assertEqual( bytes(request), b'' b"" b"alert" b"" b"", ) def test_modify_tag_with_comment(self): request = Tags.modify_tag( "tag_id", resource_type="alert", comment="comment" ) self.assertEqual( bytes(request), b'' b"comment" b"" b"alert" b"" b"", ) def test_modify_tag_with_name(self): request = Tags.modify_tag("tag_id", resource_type="alert", name="name") self.assertEqual( bytes(request), b'' b"name" b"" b"alert" b"" b"", ) def test_modify_tag_with_value(self): request = Tags.modify_tag( "tag_id", resource_type="alert", value="value" ) self.assertEqual( bytes(request), b'' b"value" b"" b"alert" b"" b"", ) def test_modify_tag_with_active(self): request = Tags.modify_tag("tag_id", resource_type="alert", active=True) self.assertEqual( bytes(request), b'' b"1" b"" b"alert" b"" b"", ) request = Tags.modify_tag("tag_id", resource_type="alert", active=False) self.assertEqual( bytes(request), b'' b"0" b"" b"alert" b"" b"", ) def test_modify_tag_with_resource_action(self): request = Tags.modify_tag("tag_id", resource_action="add") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_tag_with_resource_filter(self): request = Tags.modify_tag( "tag_id", resource_type="alert", resource_filter="filter" ) self.assertEqual( bytes(request), b'' b'' b"alert" b"" b"", ) def test_modify_tag_with_resource_ids(self): request = Tags.modify_tag("tag_id", resource_ids=["id1", "id2"]) self.assertEqual( bytes(request), b'' b"" b'' b'' b"" b"", ) def test_modify_tag_missing_tag_id(self): with self.assertRaises(RequiredArgument): Tags.modify_tag(None) with self.assertRaises(RequiredArgument): Tags.modify_tag("") def test_modify_tag_with_resource_filter_missing_resource_type(self): with self.assertRaises(RequiredArgument): Tags.modify_tag("tag_id", resource_filter="filter") with self.assertRaises(RequiredArgument): Tags.modify_tag( "tag_id", resource_filter="filter", resource_type=None ) with self.assertRaises(RequiredArgument): Tags.modify_tag( "tag_id", resource_filter="filter", resource_type="" ) def test_modify_tag_invalid_resource_type(self): with self.assertRaises(InvalidArgument): Tags.modify_tag("tag_id", resource_type="invalid") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_targets.py000066400000000000000000000455431466406635600253530ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import AliveTest, Targets class TargetsTestCase(unittest.TestCase): def test_create_target_missing_name(self): with self.assertRaises(RequiredArgument): Targets.create_target(None, hosts=["foo"]) with self.assertRaises(RequiredArgument): Targets.create_target(name=None, hosts=["foo"]) with self.assertRaises(RequiredArgument): Targets.create_target("", hosts=["foo"]) def test_create_target_missing_hosts(self): with self.assertRaises(RequiredArgument): Targets.create_target(name="foo") def test_create_target_with_hosts(self): request = Targets.create_target("foo", hosts=["foo"]) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"", ) request = Targets.create_target("foo", hosts=["foo", "bar"]) self.assertEqual( bytes(request), b"" b"foo" b"foo,bar" b"", ) def test_create_target_with_asset_hosts_filter(self): request = Targets.create_target("foo", asset_hosts_filter="name=foo") self.assertEqual( bytes(request), b"" b"foo" b'' b"", ) def test_create_target_with_comment(self): request = Targets.create_target("foo", hosts=["foo"], comment="bar") self.assertEqual( bytes(request), b"" b"foo" b"foo" b"bar" b"", ) def test_create_target_with_exclude_hosts(self): request = Targets.create_target( "foo", hosts=["foo", "bar"], exclude_hosts=["bar", "ipsum"] ) self.assertEqual( bytes(request), b"" b"foo" b"foo,bar" b"bar,ipsum" b"", ) def test_create_target_with_ssh_credential(self): request = Targets.create_target( "foo", hosts=["foo"], ssh_credential_id="c1" ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b'' b"", ) def test_create_target_with_ssh_credential_port(self): request = Targets.create_target( "foo", hosts=["foo"], ssh_credential_id="c1", ssh_credential_port=22 ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b'22' b"", ) def test_create_target_with_smb_credential_id(self): request = Targets.create_target( "foo", hosts=["foo"], smb_credential_id="c1" ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b'' b"", ) def test_create_target_with_esxi_credential_id(self): request = Targets.create_target( "foo", hosts=["foo"], esxi_credential_id="c1" ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b'' b"", ) def test_create_target_with_snmp_credential_id(self): request = Targets.create_target( "foo", hosts=["foo"], snmp_credential_id="c1" ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b'' b"", ) def test_create_target_with_alive_tests(self): request = Targets.create_target( "foo", hosts=["foo"], alive_test=AliveTest.ICMP_PING ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"ICMP Ping" b"", ) request = Targets.create_target( "foo", hosts=["foo"], alive_test="icmp ping" ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"ICMP Ping" b"", ) def test_create_target_invalid_alive_tests(self): with self.assertRaises(InvalidArgument): Targets.create_target("foo", hosts=["foo"], alive_test="foo") def test_create_target_with_allow_simultaneous_ips(self): request = Targets.create_target( "foo", hosts=["foo"], allow_simultaneous_ips=True ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"1" b"", ) request = Targets.create_target( "foo", hosts=["foo"], allow_simultaneous_ips=False ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"0" b"", ) def test_create_target_with_reverse_lookup_only(self): request = Targets.create_target( "foo", hosts=["foo"], reverse_lookup_only=True ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"1" b"", ) request = Targets.create_target( "foo", hosts=["foo"], reverse_lookup_only=False ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"0" b"", ) def test_create_target_with_reverse_lookup_unify(self): request = Targets.create_target( "foo", hosts=["foo"], reverse_lookup_unify=True ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"1" b"", ) request = Targets.create_target( "foo", hosts=["foo"], reverse_lookup_unify=False ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"0" b"", ) def test_create_target_with_port_range(self): request = Targets.create_target( "foo", hosts=["foo"], port_range="1-65535" ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b"1-65535" b"", ) def test_create_target_with_port_list_id(self): request = Targets.create_target( "foo", hosts=["foo"], port_list_id="pl1" ) self.assertEqual( bytes(request), b"" b"foo" b"foo" b'' b"", ) def test_modify_target(self): request = Targets.modify_target("t1") self.assertEqual( bytes(request), b'', ) def test_modify_target_missing_target_id(self): with self.assertRaises(RequiredArgument): Targets.modify_target(None) with self.assertRaises(RequiredArgument): Targets.modify_target("") def test_modify_target_with_comment(self): request = Targets.modify_target("t1", comment="foo") self.assertEqual( bytes(request), b'foo', ) def test_modify_target_with_hosts(self): request = Targets.modify_target("t1", hosts=["foo"]) self.assertEqual( bytes(request), b'' b"foo" b"" b"", ) request = Targets.modify_target("t1", hosts=["foo", "bar"]) self.assertEqual( bytes(request), b'' b"foo,bar" b"" b"", ) def test_modify_target_with_hosts_and_exclude_hosts(self): request = Targets.modify_target( "t1", hosts=["foo", "bar"], exclude_hosts=["foo"] ) self.assertEqual( bytes(request), b'' b"foo,bar" b"foo" b"", ) def test_modify_target_with_name(self): request = Targets.modify_target("t1", name="foo") self.assertEqual( bytes(request), b'' b"foo" b"", ) def test_modify_target_with_exclude_hosts(self): request = Targets.modify_target("t1", exclude_hosts=["foo"]) self.assertEqual( bytes(request), b'' b"foo" b"", ) request = Targets.modify_target("t1", exclude_hosts=["foo", "bar"]) self.assertEqual( bytes(request), b'' b"foo,bar" b"", ) def test_modify_target_with_ssh_credential_id(self): request = Targets.modify_target("t1", ssh_credential_id="c1") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_target_with_ssh_credential_id_and_port(self): request = Targets.modify_target( "t1", ssh_credential_id="c1", ssh_credential_port=22 ) self.assertEqual( bytes(request), b'' b'22' b"", ) def test_modify_target_with_smb_credential_id(self): request = Targets.modify_target("t1", smb_credential_id="c1") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_target_with_esxi_credential_id(self): request = Targets.modify_target("t1", esxi_credential_id="c1") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_target_with_snmp_credential_id(self): request = Targets.modify_target("t1", snmp_credential_id="c1") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_target_with_alive_tests(self): request = Targets.modify_target("t1", alive_test=AliveTest.ICMP_PING) self.assertEqual( bytes(request), b'' b"ICMP Ping" b"", ) request = Targets.modify_target("t1", alive_test="icmp ping") self.assertEqual( bytes(request), b'' b"ICMP Ping" b"", ) def test_modify_target_invalid_alive_tests(self): with self.assertRaises(InvalidArgument): Targets.modify_target("t1", alive_test="foo") def test_modify_target_with_allow_simultaneous_ips(self): request = Targets.modify_target("t1", allow_simultaneous_ips=True) self.assertEqual( bytes(request), b'' b"1" b"", ) request = Targets.modify_target("t1", allow_simultaneous_ips=False) self.assertEqual( bytes(request), b'' b"0" b"", ) def test_modify_target_with_reverse_lookup_only(self): request = Targets.modify_target("t1", reverse_lookup_only=True) self.assertEqual( bytes(request), b'' b"1" b"", ) request = Targets.modify_target("t1", reverse_lookup_only=False) self.assertEqual( bytes(request), b'' b"0" b"", ) def test_modify_target_with_reverse_lookup_unify(self): request = Targets.modify_target("t1", reverse_lookup_unify=True) self.assertEqual( bytes(request), b'' b"1" b"", ) request = Targets.modify_target("t1", reverse_lookup_unify=False) self.assertEqual( bytes(request), b'' b"0" b"", ) def test_modify_target_with_port_list_id(self): request = Targets.modify_target("t1", port_list_id="pl1") self.assertEqual( bytes(request), b'' b'' b"", ) def test_clone_target(self): request = Targets.clone_target("t1") self.assertEqual( bytes(request), b"t1", ) def test_clone_target_missing_target_id(self): with self.assertRaises(RequiredArgument): Targets.clone_target(None) with self.assertRaises(RequiredArgument): Targets.clone_target("") def test_delete_target(self): request = Targets.delete_target("t1") self.assertEqual( bytes(request), b'', ) def test_delete_ultimate(self): request = Targets.delete_target("t1", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Targets.delete_target("t1", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_target_missing_target_id(self): with self.assertRaises(RequiredArgument): Targets.delete_target(None) with self.assertRaises(RequiredArgument): Targets.delete_target("") def test_get_target(self): request = Targets.get_target("t1") self.assertEqual( bytes(request), b'', ) def test_get_target_with_tasks(self): request = Targets.get_target("t1", tasks=True) self.assertEqual( bytes(request), b'', ) request = Targets.get_target("t1", tasks=False) self.assertEqual( bytes(request), b'', ) def test_get_target_missing_target_id(self): with self.assertRaises(RequiredArgument): Targets.get_target(None) with self.assertRaises(RequiredArgument): Targets.get_target("") def test_get_targets(self): request = Targets.get_targets() self.assertEqual( bytes(request), b"", ) def test_get_targets_with_filter_string(self): request = Targets.get_targets(filter_string="foo=bar") self.assertEqual( bytes(request), b'', ) def test_get_targets_with_filter_id(self): request = Targets.get_targets(filter_id="f1") self.assertEqual( bytes(request), b'', ) def test_get_targets_with_trash(self): request = Targets.get_targets(trash=True) self.assertEqual( bytes(request), b'', ) request = Targets.get_targets(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_targets_with_tasks(self): request = Targets.get_targets(tasks=True) self.assertEqual( bytes(request), b'', ) request = Targets.get_targets(tasks=False) self.assertEqual( bytes(request), b'', ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_tasks.py000066400000000000000000000557421466406635600250310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import HostsOrdering, Tasks class TasksTestCase(unittest.TestCase): def test_clone_task(self): request = Tasks().clone_task("task_id") self.assertEqual( bytes(request), b"task_id", ) def test_clone_task_invalid(self): with self.assertRaises(RequiredArgument): Tasks().clone_task(None) with self.assertRaises(RequiredArgument): Tasks().clone_task("") def test_create_container_task(self): request = Tasks().create_container_task("name") self.assertEqual( bytes(request), b"" b"name" b'' b"", ) def test_create_container_task_with_comment(self): request = Tasks().create_container_task("name", comment="comment") self.assertEqual( bytes(request), b"" b"name" b'' b"comment" b"", ) def test_create_task(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b"", ) def test_create_task_with_comment(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", comment="comment", ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b"comment" b"", ) def test_create_task_with_alterable(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", alterable=True, ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b"1" b"", ) request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", alterable=False, ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b"0" b"", ) def test_create_task_with_hosts_ordering(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", hosts_ordering="random", ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b"random" b"", ) request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", hosts_ordering=HostsOrdering.RANDOM, ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b"random" b"", ) def test_create_task_with_alert_ids(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", alert_ids=["alert_id1", "alert_id2"], ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b'' b'' b"", ) def test_create_task_with_schedule_id(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", schedule_id="schedule_id", ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b'' b"", ) def test_create_task_with_scanner_id_and_schedule_periods(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", schedule_id="schedule_id", schedule_periods=5, ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b'' b"5" b"", ) def test_create_task_with_scanner_id_and_invalid_schedule_periods(self): with self.assertRaises(InvalidArgument): Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", schedule_id="schedule_id", schedule_periods=-1, ) with self.assertRaises(InvalidArgument): Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", schedule_id="schedule_id", schedule_periods="invalid", ) def test_create_task_with_observers(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", observers=["observer_id1", "observer_id2"], ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b"observer_id1,observer_id2" b"", ) def test_create_task_with_preferences(self): request = Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", preferences={"key1": "value1", "key2": "value2"}, ) self.assertEqual( bytes(request), b"" b"name" b"scan" b'' b'' b'' b"" b"" b"key1" b"value1" b"" b"" b"key2" b"value2" b"" b"" b"", ) def test_create_task_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgument): Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="scanner_id", hosts_ordering="invalid", ) def test_create_task_missing_name(self): with self.assertRaises(RequiredArgument): Tasks().create_task( "", target_id="target_id", config_id="config_id", scanner_id="scanner_id", ) with self.assertRaises(RequiredArgument): Tasks().create_task( None, target_id="target_id", config_id="config_id", scanner_id="scanner_id", ) def test_create_task_missing_target_id(self): with self.assertRaises(RequiredArgument): Tasks().create_task( "name", target_id="", config_id="config_id", scanner_id="scanner_id", ) with self.assertRaises(RequiredArgument): Tasks().create_task( "name", target_id=None, config_id="config_id", scanner_id="scanner_id", ) def test_create_task_missing_config_id(self): with self.assertRaises(RequiredArgument): Tasks().create_task( "name", target_id="target_id", config_id="", scanner_id="scanner_id", ) with self.assertRaises(RequiredArgument): Tasks().create_task( "name", target_id="target_id", config_id=None, scanner_id="scanner_id", ) def test_create_task_missing_scanner_id(self): with self.assertRaises(RequiredArgument): Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id="", ) with self.assertRaises(RequiredArgument): Tasks().create_task( "name", target_id="target_id", config_id="config_id", scanner_id=None, ) def test_delete_task(self): request = Tasks().delete_task("task_id") self.assertEqual( bytes(request), b'', ) def test_delete_task_with_ultimate(self): request = Tasks().delete_task("task_id", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Tasks().delete_task("task_id", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_task_missing_task_id(self): with self.assertRaises(RequiredArgument): Tasks().delete_task("") with self.assertRaises(RequiredArgument): Tasks().delete_task(None) def test_get_tasks(self): request = Tasks().get_tasks() self.assertEqual( bytes(request), b'', ) def test_get_tasks_with_filter_string(self): request = Tasks().get_tasks(filter_string="filter_string") self.assertEqual( bytes(request), b'', ) def test_get_tasks_with_filter_id(self): request = Tasks().get_tasks(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_tasks_with_trash(self): request = Tasks().get_tasks(trash=True) self.assertEqual( bytes(request), b'', ) request = Tasks().get_tasks(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_tasks_with_details(self): request = Tasks().get_tasks(details=True) self.assertEqual( bytes(request), b'', ) request = Tasks().get_tasks(details=False) self.assertEqual( bytes(request), b'', ) def test_get_tasks_with_schedules_only(self): request = Tasks().get_tasks(schedules_only=True) self.assertEqual( bytes(request), b'', ) request = Tasks().get_tasks(schedules_only=False) self.assertEqual( bytes(request), b'', ) def test_get_tasks_with_ignore_pagination(self): request = Tasks().get_tasks(ignore_pagination=True) self.assertEqual( bytes(request), b'', ) request = Tasks().get_tasks(ignore_pagination=False) self.assertEqual( bytes(request), b'', ) def test_get_task(self): request = Tasks().get_task("task_id") self.assertEqual( bytes(request), b'', ) def test_get_task_missing_task_id(self): with self.assertRaises(RequiredArgument): Tasks().get_task("") with self.assertRaises(RequiredArgument): Tasks().get_task(None) def test_modify_task(self): request = Tasks().modify_task("task_id") self.assertEqual( bytes(request), b'', ) def test_modify_task_with_name(self): request = Tasks().modify_task("task_id", name="name") self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_task_with_config_id(self): request = Tasks().modify_task("task_id", config_id="config_id") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_task_with_comment(self): request = Tasks().modify_task("task_id", comment="comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_task_with_target_id(self): request = Tasks().modify_task("task_id", target_id="target_id") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_task_with_alterable(self): request = Tasks().modify_task("task_id", alterable=True) self.assertEqual( bytes(request), b'' b"1" b"", ) request = Tasks().modify_task("task_id", alterable=False) self.assertEqual( bytes(request), b'' b"0" b"", ) def test_modify_task_with_hosts_ordering(self): request = Tasks().modify_task("task_id", hosts_ordering="random") self.assertEqual( bytes(request), b'' b"random" b"", ) request = Tasks().modify_task( "task_id", hosts_ordering=HostsOrdering.RANDOM ) self.assertEqual( bytes(request), b'' b"random" b"", ) def test_modify_task_with_scanner_id(self): request = Tasks().modify_task("task_id", scanner_id="scanner_id") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_task_with_schedule_id(self): request = Tasks().modify_task("task_id", schedule_id="schedule_id") self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_task_with_schedule_periods(self): request = Tasks().modify_task("task_id", schedule_periods=5) self.assertEqual( bytes(request), b'' b"5" b"", ) def test_modify_task_with_alert_ids(self): request = Tasks().modify_task( "task_id", alert_ids=["alert_id1", "alert_id2"] ) self.assertEqual( bytes(request), b'' b'' b'' b"", ) request = Tasks().modify_task("task_id", alert_ids=[]) self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_task_with_observers(self): request = Tasks().modify_task( "task_id", observers=["observer_id1", "observer_id2"] ) self.assertEqual( bytes(request), b'' b"observer_id1,observer_id2" b"", ) request = Tasks().modify_task("task_id", observers=[]) self.assertEqual( bytes(request), b'' b"" b"", ) def test_modify_task_with_preferences(self): request = Tasks().modify_task( "task_id", preferences={"key1": "value1", "key2": "value2"} ) self.assertEqual( bytes(request), b'' b"" b"" b"key1" b"value1" b"" b"" b"key2" b"value2" b"" b"" b"", ) request = Tasks().modify_task("task_id", preferences={}) self.assertEqual( bytes(request), b'' b"" b"", ) def test_modify_task_missing_task_id(self): with self.assertRaises(RequiredArgument): Tasks().modify_task("") with self.assertRaises(RequiredArgument): Tasks().modify_task(None) def test_modify_task_invalid_schedule_periods(self): with self.assertRaises(InvalidArgument): Tasks().modify_task("task_id", schedule_periods=-1) with self.assertRaises(InvalidArgument): Tasks().modify_task("task_id", schedule_periods="invalid") def test_modify_task_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgument): Tasks().modify_task("task_id", hosts_ordering="invalid") def test_move_task(self): request = Tasks().move_task("task_id") self.assertEqual( bytes(request), b'', ) def test_move_task_with_slave_id(self): request = Tasks().move_task("task_id", slave_id="slave_id") self.assertEqual( bytes(request), b'', ) def test_move_task_missing_task_id(self): with self.assertRaises(RequiredArgument): Tasks().move_task("") with self.assertRaises(RequiredArgument): Tasks().move_task(None) def test_start_task(self): request = Tasks().start_task("task_id") self.assertEqual( bytes(request), b'', ) def test_start_task_missing_task_id(self): with self.assertRaises(RequiredArgument): Tasks().start_task("") with self.assertRaises(RequiredArgument): Tasks().start_task(None) def test_resume_task(self): request = Tasks().resume_task("task_id") self.assertEqual( bytes(request), b'', ) def test_resume_task_missing_task_id(self): with self.assertRaises(RequiredArgument): Tasks().resume_task("") with self.assertRaises(RequiredArgument): Tasks().resume_task(None) def test_stop_task(self): request = Tasks().stop_task("task_id") self.assertEqual( bytes(request), b'', ) def test_stop_task_missing_task_id(self): with self.assertRaises(RequiredArgument): Tasks().stop_task("") with self.assertRaises(RequiredArgument): Tasks().stop_task(None) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_tickets.py000066400000000000000000000200451466406635600253360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import Tickets, TicketStatus class TicketsTestCase(unittest.TestCase): def test_clone_ticket(self): request = Tickets.clone_ticket("ticket_id") self.assertEqual( bytes(request), b"ticket_id", ) def test_clone_ticket_missing_ticket_id(self): with self.assertRaises(RequiredArgument): Tickets.clone_ticket(None) with self.assertRaises(RequiredArgument): Tickets.clone_ticket("") def test_create_ticket(self): request = Tickets.create_ticket( result_id="result_id", assigned_to_user_id="user_id", note="note", ) self.assertEqual( bytes(request), b"" b'' b'' b"note" b"", ) def test_create_ticket_with_comment(self): request = Tickets.create_ticket( result_id="result_id", assigned_to_user_id="user_id", note="note", comment="comment", ) self.assertEqual( bytes(request), b"" b'' b'' b"note" b"comment" b"", ) def test_create_ticket_missing_result_id(self): with self.assertRaises(RequiredArgument): Tickets.create_ticket( result_id=None, assigned_to_user_id="user_id", note="note" ) with self.assertRaises(RequiredArgument): Tickets.create_ticket( result_id="", assigned_to_user_id="user_id", note="note" ) def test_create_ticket_missing_assigned_to_user_id(self): with self.assertRaises(RequiredArgument): Tickets.create_ticket( result_id="result_id", assigned_to_user_id=None, note="note" ) with self.assertRaises(RequiredArgument): Tickets.create_ticket( result_id="result_id", assigned_to_user_id="", note="note" ) def test_create_ticket_missing_note(self): with self.assertRaises(RequiredArgument): Tickets.create_ticket( result_id="result_id", assigned_to_user_id="user_id", note=None ) with self.assertRaises(RequiredArgument): Tickets.create_ticket( result_id="result_id", assigned_to_user_id="user_id", note="" ) def test_delete_ticket(self): request = Tickets.delete_ticket("ticket_id") self.assertEqual( bytes(request), b'', ) def test_delete_ticket_with_ultimate(self): request = Tickets.delete_ticket("ticket_id", ultimate=True) self.assertEqual( bytes(request), b'', ) request = Tickets.delete_ticket("ticket_id", ultimate=False) self.assertEqual( bytes(request), b'', ) def test_delete_ticket_missing_ticket_id(self): with self.assertRaises(RequiredArgument): Tickets.delete_ticket(None) with self.assertRaises(RequiredArgument): Tickets.delete_ticket("") def test_get_tickets(self): request = Tickets.get_tickets() self.assertEqual( bytes(request), b"", ) def test_get_tickets_with_filter_string(self): request = Tickets.get_tickets(filter_string="filter") self.assertEqual( bytes(request), b'', ) def test_get_tickets_with_filter_id(self): request = Tickets.get_tickets(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_tickets_with_trash(self): request = Tickets.get_tickets(trash=True) self.assertEqual( bytes(request), b'', ) request = Tickets.get_tickets(trash=False) self.assertEqual( bytes(request), b'', ) def test_get_ticket(self): request = Tickets.get_ticket("ticket_id") self.assertEqual( bytes(request), b'', ) def test_get_ticket_missing_ticket_id(self): with self.assertRaises(RequiredArgument): Tickets.get_ticket(None) with self.assertRaises(RequiredArgument): Tickets.get_ticket("") def test_modify_ticket(self): request = Tickets.modify_ticket("ticket_id") self.assertEqual( bytes(request), b'', ) def test_modify_ticket_with_status_and_note(self): request = Tickets.modify_ticket( "ticket_id", status=TicketStatus.FIXED, note="note" ) self.assertEqual( bytes(request), b'' b"Fixed" b"note" b"", ) request = Tickets.modify_ticket( "ticket_id", status="fixed", note="note" ) self.assertEqual( bytes(request), b'' b"Fixed" b"note" b"", ) def test_modify_ticket_with_assigned_to_user_id(self): request = Tickets.modify_ticket( "ticket_id", assigned_to_user_id="user_id" ) self.assertEqual( bytes(request), b'' b'' b"", ) def test_modify_ticket_with_comment(self): request = Tickets.modify_ticket("ticket_id", comment="comment") self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_ticket_missing_ticket_id(self): with self.assertRaises(RequiredArgument): Tickets.modify_ticket(None) with self.assertRaises(RequiredArgument): Tickets.modify_ticket("") def test_modify_ticket_with_status_missing_note(self): with self.assertRaises(RequiredArgument): Tickets.modify_ticket("ticket_id", status=TicketStatus.FIXED) with self.assertRaises(RequiredArgument): Tickets.modify_ticket( "ticket_id", status=TicketStatus.FIXED, note=None ) with self.assertRaises(RequiredArgument): Tickets.modify_ticket( "ticket_id", status=TicketStatus.FIXED, note="" ) def test_modify_ticket_with_note_missing_status(self): with self.assertRaises(RequiredArgument): Tickets.modify_ticket("ticket_id", note="note") with self.assertRaises(RequiredArgument): Tickets.modify_ticket("ticket_id", note="note", status=None) with self.assertRaises(RequiredArgument): Tickets.modify_ticket("ticket_id", note="note", status="") def test_modify_ticket_invalid_status(self): with self.assertRaises(InvalidArgument): Tickets.modify_ticket("ticket_id", note="note", status="invalid") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_tls_certificates.py000066400000000000000000000200501466406635600272130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import TLSCertificates class TLSCertificatesTestCase(unittest.TestCase): def test_clone_tls_certificate(self): request = TLSCertificates.clone_tls_certificate("tls_certificate_id") self.assertEqual( bytes(request), b"" b"tls_certificate_id" b"", ) def test_clone_tls_certificate_missing_tls_certificate_id(self): with self.assertRaises(RequiredArgument): TLSCertificates.clone_tls_certificate(None) with self.assertRaises(RequiredArgument): TLSCertificates.clone_tls_certificate("") def test_create_tls_certificate(self): request = TLSCertificates.create_tls_certificate( name="name", certificate="certificate", ) self.assertEqual( bytes(request), b"" b"name" b"certificate" b"", ) def test_create_tls_certificate_with_comment(self): request = TLSCertificates.create_tls_certificate( name="name", certificate="certificate", comment="comment", ) self.assertEqual( bytes(request), b"" b"name" b"certificate" b"comment" b"", ) def test_create_tls_certificate_with_trust(self): request = TLSCertificates.create_tls_certificate( name="name", certificate="certificate", trust=True, ) self.assertEqual( bytes(request), b"" b"name" b"certificate" b"1" b"", ) request = TLSCertificates.create_tls_certificate( name="name", certificate="certificate", trust=False, ) self.assertEqual( bytes(request), b"" b"name" b"certificate" b"0" b"", ) def test_create_tls_certificate_missing_name(self): with self.assertRaises(RequiredArgument): TLSCertificates.create_tls_certificate( name=None, certificate="certificate", ) with self.assertRaises(RequiredArgument): TLSCertificates.create_tls_certificate( name="", certificate="certificate", ) def test_create_tls_certificate_missing_certificate(self): with self.assertRaises(RequiredArgument): TLSCertificates.create_tls_certificate( name="name", certificate=None, ) with self.assertRaises(RequiredArgument): TLSCertificates.create_tls_certificate( name="name", certificate="", ) def test_delete_tls_certificate(self): request = TLSCertificates.delete_tls_certificate("tls_certificate_id") self.assertEqual( bytes(request), b'', ) def test_delete_tls_certificate_missing_tls_certificate_id(self): with self.assertRaises(RequiredArgument): TLSCertificates.delete_tls_certificate(None) with self.assertRaises(RequiredArgument): TLSCertificates.delete_tls_certificate("") def test_get_tls_certificates(self): request = TLSCertificates.get_tls_certificates() self.assertEqual( bytes(request), b"", ) def test_get_tls_certificates_with_filter_string(self): request = TLSCertificates.get_tls_certificates( filter_string="filter_string" ) self.assertEqual( bytes(request), b'', ) def test_get_tls_certificates_with_filter_id(self): request = TLSCertificates.get_tls_certificates(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_tls_certificates_with_details(self): request = TLSCertificates.get_tls_certificates(details=True) self.assertEqual( bytes(request), b'', ) request = TLSCertificates.get_tls_certificates(details=False) self.assertEqual( bytes(request), b'', ) def test_get_tls_certificates_with_include_certificate_data(self): request = TLSCertificates.get_tls_certificates( include_certificate_data=True ) self.assertEqual( bytes(request), b'', ) request = TLSCertificates.get_tls_certificates( include_certificate_data=False ) self.assertEqual( bytes(request), b'', ) def test_get_tls_certificate(self): request = TLSCertificates.get_tls_certificate("tls_certificate_id") self.assertEqual( bytes(request), b'', ) def test_get_tls_certificate_missing_tls_certificate_id(self): with self.assertRaises(RequiredArgument): TLSCertificates.get_tls_certificate(None) with self.assertRaises(RequiredArgument): TLSCertificates.get_tls_certificate("") def test_modify_tls_certificate(self): request = TLSCertificates.modify_tls_certificate( "tls_certificate_id", ) self.assertEqual( bytes(request), b'', ) def test_modify_tls_certificate_with_name(self): request = TLSCertificates.modify_tls_certificate( "tls_certificate_id", name="name", ) self.assertEqual( bytes(request), b'' b"name" b"", ) def test_modify_tls_certificate_with_comment(self): request = TLSCertificates.modify_tls_certificate( "tls_certificate_id", comment="comment", ) self.assertEqual( bytes(request), b'' b"comment" b"", ) def test_modify_tls_certificate_with_trust(self): request = TLSCertificates.modify_tls_certificate( "tls_certificate_id", trust=True, ) self.assertEqual( bytes(request), b'' b"1" b"", ) request = TLSCertificates.modify_tls_certificate( "tls_certificate_id", trust=False, ) self.assertEqual( bytes(request), b'' b"0" b"", ) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_trashcan.py000066400000000000000000000013001466406635600254640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import TrashCan class TrashCanTestCase(unittest.TestCase): def test_empty_trashcan(self): request = TrashCan.empty_trashcan() self.assertEqual(bytes(request), b"") def test_restore_from_trashcan(self): request = TrashCan.restore_from_trashcan("1") self.assertEqual(bytes(request), b'') def test_restore_from_trashcan_with_empty_id(self): with self.assertRaises(RequiredArgument): TrashCan.restore_from_trashcan("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_user_settings.py000066400000000000000000000050341466406635600265670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import UserSettings class UserSettingsTestCase(unittest.TestCase): def test_get_user_setting(self): request = UserSettings.get_user_setting("id") self.assertEqual(bytes(request), b'') def test_get_user_setting_missing_setting_id(self): with self.assertRaises(RequiredArgument): UserSettings.get_user_setting(setting_id=None) with self.assertRaises(RequiredArgument): UserSettings.get_user_setting("") def test_get_user_settings(self): request = UserSettings.get_user_settings() self.assertEqual(bytes(request), b"") def test_get_user_settings_with_filter_string(self): request = UserSettings.get_user_settings(filter_string="foo=bar") self.assertEqual(bytes(request), b'') def test_modify_user_setting(self): request = UserSettings.modify_user_setting( setting_id="id", value="value" ) self.assertEqual( bytes(request), b'dmFsdWU=', ) request = UserSettings.modify_user_setting(name="name", value="value") self.assertEqual( bytes(request), b"namedmFsdWU=", ) request = UserSettings.modify_user_setting(name="name", value="") self.assertEqual( bytes(request), b"name", ) def test_modify_user_setting_missing_setting_id(self): with self.assertRaises(RequiredArgument): UserSettings.modify_user_setting(setting_id=None, value="value") with self.assertRaises(RequiredArgument): UserSettings.modify_user_setting(setting_id="", value="value") def test_modify_setting_missing_name(self): with self.assertRaises(RequiredArgument): UserSettings.modify_user_setting(name=None, value="value") with self.assertRaises(RequiredArgument): UserSettings.modify_user_setting(name="", value="value") def test_modify_user_setting_missing_value(self): with self.assertRaises(RequiredArgument): UserSettings.modify_user_setting(setting_id="id", value=None) python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_users.py000066400000000000000000000201351466406635600250310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import UserAuthType, Users class UsersTestCase(unittest.TestCase): def test_get_users(self): request = Users().get_users() self.assertEqual(bytes(request), b"") def test_get_users_with_filter_string(self): request = Users().get_users(filter_string="foo=bar") self.assertEqual(bytes(request), b'') def test_get_users_with_filter_id(self): request = Users().get_users(filter_id="f1") self.assertEqual(bytes(request), b'') def test_create_user(self): request = Users().create_user(name="foo") self.assertEqual( bytes(request), b"foo" ) def test_create_user_with_password(self): request = Users().create_user(name="foo", password="bar") self.assertEqual( bytes(request), b"foobar", ) def test_create_user_with_hosts(self): request = Users().create_user( name="foo", hosts=["h1", "h2"], hosts_allow=True ) self.assertEqual( bytes(request), b"" b"foo" b'h1,h2' b"", ) request = Users().create_user( name="foo", hosts=["h1", "h2"], hosts_allow=False ) self.assertEqual( bytes(request), b"" b"foo" b'h1,h2' b"", ) def test_create_user_with_role_ids(self): request = Users().create_user(name="foo", role_ids=["r1", "r2"]) self.assertEqual( bytes(request), b"" b"foo" b'' b'' b"", ) def test_create_user_missing_name(self): with self.assertRaises(RequiredArgument): Users().create_user("") with self.assertRaises(RequiredArgument): Users().create_user(None) def test_modify_user(self): request = Users().modify_user(user_id="u1") self.assertEqual(bytes(request), b'') def test_modify_user_missing_user_id(self): with self.assertRaises(RequiredArgument): Users().modify_user(user_id=None) with self.assertRaises(RequiredArgument): Users().modify_user(user_id="") def test_modify_user_with_new_name(self): request = Users().modify_user(user_id="u1", name="foo") self.assertEqual( bytes(request), b'foo', ) def test_modify_user_with_new_comment(self): request = Users().modify_user(user_id="u1", comment="foo") self.assertEqual( bytes(request), b'foo', ) def test_modify_user_with_role_ids(self): request = Users().modify_user(user_id="u1", role_ids=[]) self.assertEqual(bytes(request), b'') request = Users().modify_user(user_id="u1", role_ids=["r1"]) self.assertEqual( bytes(request), b'', ) request = Users().modify_user(user_id="u1", role_ids=["r1", "r2"]) self.assertEqual( bytes(request), b'', ) def test_modify_user_with_group_ids(self): request = Users().modify_user(user_id="u1", group_ids=[]) self.assertEqual(bytes(request), b'') request = Users().modify_user(user_id="u1", group_ids=["g1"]) self.assertEqual( bytes(request), b'', ) request = Users().modify_user(user_id="u1", group_ids=["g1", "g2"]) self.assertEqual( bytes(request), b'', ) def test_modify_user_with_password(self): request = Users().modify_user(user_id="u1", password="bar") self.assertEqual( bytes(request), b'bar', ) def test_modify_user_with_auth_source(self): request = Users().modify_user( user_id="u1", auth_source=UserAuthType.LDAP_CONNECT ) self.assertEqual( bytes(request), b'' b"ldap_connect" b"", ) request = Users().modify_user(user_id="u1", auth_source="ldap_connect") self.assertEqual( bytes(request), b'' b"ldap_connect" b"", ) def test_modify_user_invalid_auth_source(self): with self.assertRaises(InvalidArgument): Users().modify_user(user_id="u1", auth_source="foo") def test_modify_user_with_hosts(self): request = Users().modify_user( user_id="u1", hosts=["h1", "h2"], hosts_allow=True ) self.assertEqual( bytes(request), b'' b'h1,h2' b"", ) request = Users().modify_user( user_id="u1", hosts=["h1", "h2"], hosts_allow=False ) self.assertEqual( bytes(request), b'' b'h1,h2' b"", ) def test_clone_user(self): request = Users().clone_user(user_id="u1") self.assertEqual( bytes(request), b"u1" ) def test_clone_user_missing_user_id(self): with self.assertRaises(RequiredArgument): Users().clone_user(user_id=None) with self.assertRaises(RequiredArgument): Users().clone_user(user_id="") def test_delete_user_with_user_id(self): request = Users().delete_user("u1") self.assertEqual(bytes(request), b'') def test_delete_user_with_name(self): request = Users().delete_user(name="foo") self.assertEqual(bytes(request), b'') def test_delete_user_with_inheritor_id(self): request = Users().delete_user("u1", inheritor_id="u2") self.assertEqual( bytes(request), b'' ) def test_delete_user_with_inheritor_name(self): request = Users().delete_user("u1", inheritor_name="foo") self.assertEqual( bytes(request), b'' ) def test_delete_user_missing_user_id_and_name(self): with self.assertRaises(RequiredArgument): Users().delete_user(None) with self.assertRaises(RequiredArgument): Users().delete_user("") with self.assertRaises(RequiredArgument): Users().delete_user(user_id="", name="") def test_get_user(self): request = Users().get_user("u1") self.assertEqual(bytes(request), b'') def test_get_user_missing_user_id(self): with self.assertRaises(RequiredArgument): Users().get_user(user_id=None) with self.assertRaises(RequiredArgument): Users().get_user("") python-gvm-24.8.0/tests/protocols/gmp/requests/v224/test_vulnerabilities.py000066400000000000000000000026411466406635600270730ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import Vulnerabilities class VulnerabilitiesTestCase(unittest.TestCase): def test_get_vulnerabilities(self): request = Vulnerabilities.get_vulnerabilities() self.assertEqual(bytes(request), b"") def test_get_vulnerabilities_with_filter_string(self): request = Vulnerabilities.get_vulnerabilities( filter_string="filter_string" ) self.assertEqual( bytes(request), b'', ) def test_get_vulnerabilities_with_filter_id(self): request = Vulnerabilities.get_vulnerabilities(filter_id="filter_id") self.assertEqual( bytes(request), b'', ) def test_get_vulnerability(self): request = Vulnerabilities.get_vulnerability("vulnerability_id") self.assertEqual( bytes(request), b'', ) def test_get_vulnerability_missing_vulnerability_id(self): with self.assertRaises(RequiredArgument): Vulnerabilities.get_vulnerability(None) with self.assertRaises(RequiredArgument): Vulnerabilities.get_vulnerability("") python-gvm-24.8.0/tests/protocols/gmp/requests/v225/000077500000000000000000000000001466406635600222575ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmp/requests/v225/__init__.py000066400000000000000000000001321466406635600243640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later python-gvm-24.8.0/tests/protocols/gmp/requests/v225/test_resource_names.py000066400000000000000000000321151466406635600267040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.core import Request from gvm.protocols.gmp.requests.v225 import ResourceNames, ResourceType class ResourceNamesTestCase(unittest.TestCase): def test_get_resource_names(self) -> None: request = ResourceNames.get_resource_names(ResourceType.ALERT) self.assertIsInstance(request, Request) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.CERT_BUND_ADV) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.CONFIG) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names( resource_type=ResourceType.CPE ) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.CREDENTIAL) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.CVE) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.DFN_CERT_ADV) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.FILTER) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.GROUP) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.HOST) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.NOTE) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.NVT) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.OS) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.OVERRIDE) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.PERMISSION) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.PORT_LIST) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.REPORT_FORMAT) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.REPORT) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.RESULT) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.ROLE) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.SCANNER) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.SCHEDULE) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.TARGET) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.TASK) self.assertEqual(bytes(request), b'') request = ResourceNames.get_resource_names(ResourceType.TLS_CERTIFICATE) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_names(ResourceType.USER) self.assertEqual(bytes(request), b'') def test_get_resource_names_missing_resource_type(self) -> None: with self.assertRaises(RequiredArgument): ResourceNames.get_resource_names(resource_type=None) # type: ignore with self.assertRaises(RequiredArgument): ResourceNames.get_resource_names(resource_type="") with self.assertRaises(RequiredArgument): ResourceNames.get_resource_names("") def test_get_resource_names_invalid_resource_type(self) -> None: with self.assertRaises(InvalidArgument): ResourceNames.get_resource_names(resource_type="foo") def test_get_resource_names_with_filter_string(self) -> None: request = ResourceNames.get_resource_names( ResourceType.CPE, filter_string="foo=bar" ) self.assertEqual( bytes(request), b'' ) def test_get_resource_name(self): request = ResourceNames.get_resource_name( resource_type=ResourceType.ALERT, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.CERT_BUND_ADV, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.CONFIG, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.CPE, resource_id="i1" ) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_name( resource_type=ResourceType.CREDENTIAL, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.CVE, resource_id="i1" ) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_name( resource_type=ResourceType.DFN_CERT_ADV, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.FILTER, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.GROUP, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.HOST, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.NOTE, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.NVT, resource_id="i1" ) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_name( resource_type=ResourceType.OS, resource_id="i1" ) self.assertEqual( bytes(request), b'' ) request = ResourceNames.get_resource_name( resource_type=ResourceType.PERMISSION, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.PORT_LIST, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.REPORT_FORMAT, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.REPORT, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.RESULT, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.ROLE, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.SCANNER, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.SCHEDULE, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.TARGET, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.TASK, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.TLS_CERTIFICATE, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) request = ResourceNames.get_resource_name( resource_type=ResourceType.USER, resource_id="i1" ) self.assertEqual( bytes(request), b'', ) def test_get_resource_name_missing_resource_type(self): with self.assertRaises(RequiredArgument): ResourceNames.get_resource_name( resource_id="i1", resource_type=None ) with self.assertRaises(RequiredArgument): ResourceNames.get_resource_name(resource_id="i1", resource_type="") with self.assertRaises(RequiredArgument): ResourceNames.get_resource_name("i1", "") def test_get_resource_name_invalid_resource_type(self): with self.assertRaises(InvalidArgument): ResourceNames.get_resource_name( resource_id="i1", resource_type="foo" ) def test_get_resource_name_missing_resource_id(self): with self.assertRaises(RequiredArgument): ResourceNames.get_resource_name( resource_id="", resource_type=ResourceType.CPE ) with self.assertRaises(RequiredArgument): ResourceNames.get_resource_name("", resource_type=ResourceType.CPE) with self.assertRaises(RequiredArgument): ResourceNames.get_resource_name( resource_id=None, resource_type=ResourceType.CPE ) python-gvm-24.8.0/tests/protocols/gmp/test_context_manager.py000066400000000000000000000102301466406635600244710ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from unittest.mock import MagicMock, patch from gvm.errors import GvmError from gvm.protocols.gmp import Gmp from gvm.protocols.gmp._gmp224 import GMPv224 from gvm.protocols.gmp._gmp225 import GMPv225 from tests.protocols import GmpTestCase class GmpContextManagerTestCase(GmpTestCase): gmp_class = Gmp def test_select_gmpv7(self): self.connection.read.return_value( b'' b"7.0" b"" ) with self.assertRaises(GvmError): with self.gmp: pass def test_select_gmpv8(self): self.connection.read.return_value( b'' b"8.0" b"" ) with self.assertRaises(GvmError): with self.gmp: pass def test_select_gmpv9(self): self.connection.read.return_value( b'' b"9.0" b"" ) with self.assertRaises(GvmError): with self.gmp: pass def test_select_gmpv208(self): self.connection.read.return_value( b'' b"20.08" b"" ) with self.assertRaises(GvmError): with self.gmp: pass def test_select_gmpv214(self): self.connection.read.return_value( b'' b"21.04" b"" ) with self.assertRaises(GvmError): with self.gmp: pass def test_select_gmpv224(self): self.connection.read.return_value( b'' b"22.04" b"" ) with self.gmp as gmp: self.assertEqual(gmp.get_protocol_version(), (22, 4)) self.assertIsInstance(gmp, GMPv224) def test_select_gmpv225(self): self.connection.read.return_value( b'' b"22.05" b"" ) with self.gmp as gmp: self.assertEqual(gmp.get_protocol_version(), (22, 5)) self.assertIsInstance(gmp, GMPv225) def test_unknown_protocol(self): self.connection.read.return_value( b'' b"1.0" b"" ) with self.assertRaises(GvmError): with self.gmp: pass def test_missing_version_in_response(self): self.connection.read.return_value( b'' b"bar" b"" ) with self.assertRaises(GvmError): with self.gmp: pass def test_invalid_response(self): self.connection.read.return_value(b"") with self.assertRaises(GvmError): with self.gmp: pass @patch("gvm.protocols.gmp._gmp.GMPv224", autospec=True) def test_connect_disconnect(self, gmp_mock: MagicMock): self.connection.read.return_value( b'' b"22.04" b"" ) with self.gmp: gmp_mock.assert_called_once() mock_instance = gmp_mock.return_value mock_instance.connect.assert_called_once() mock_instance.disconnect.assert_called_once() if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/gmpv224/000077500000000000000000000000001466406635600203245ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/__init__.py000066400000000000000000000003431466406635600224350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.protocols.gmp import GMPv224 from .. import GmpTestCase class Gmpv224TestCase(GmpTestCase): gmp_class = GMPv224 python-gvm-24.8.0/tests/protocols/gmpv224/entities/000077500000000000000000000000001466406635600221505ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/__init__.py000066400000000000000000000001411466406635600242550ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/protocols/gmpv224/entities/alerts/000077500000000000000000000000001466406635600234425ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/alerts/__init__.py000066400000000000000000000014141466406635600255530ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneAlertTestMixin", "GmpCreateAlertTestMixin", "GmpDeleteAlertTestMixin", "GmpGetAlertTestMixin", "GmpGetAlertsTestMixin", "GmpModifyAlertTestMixin", "GmpTestAlertTestMixin", "GmpTriggerAlertTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/alerts/test_clone_alert.py000066400000000000000000000010621466406635600273410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneAlertTestMixin: def test_clone(self): self.gmp.clone_alert("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/alerts/test_create_alert.py000066400000000000000000000334341466406635600275140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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(InvalidArgument): 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(InvalidArgument): self.gmp.create_alert( name="foo", condition=AlertCondition.ALWAYS, event="lorem", method=AlertMethod.EMAIL, ) def test_invalid_method(self): with self.assertRaises(InvalidArgument): 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( b"" b"foo" b"Always" b"Task run status changed" b"Email" b"" ) 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( b"" b"foo" b"Always" b"Task run status changed" b"Email" b'' b"" ) 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( b"" b"foo" b"Always" b"Task run status changed" b"Email" b"hello" b"" ) 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( b"" b"foo" b"Alwaysbarfoo" b"Task run status changed" b"Email" b"" ) 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( b"" b"foo" b"Always" b"Task run status changed" b"barfoo" b"" b"Email" b"" ) 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( b"" b"foo" b"Always" b"Task run status changed" b"Emailbarfoo" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/alerts/test_delete_alert.py000066400000000000000000000014131466406635600275030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpDeleteAlertTestMixin: def test_delete(self): self.gmp.delete_alert("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_alert("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/alerts/test_get_alert.py000066400000000000000000000021211466406635600270150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetAlertTestMixin: def test_get_alert(self): self.gmp.get_alert("a1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_alert(alert_id="a1") self.connection.send.has_been_called_with( b'' ) 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( b'' ) self.gmp.get_alert(alert_id="a1", tasks=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/alerts/test_get_alerts.py000066400000000000000000000022711466406635600272060ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetAlertsTestMixin: def test_get_alerts(self): self.gmp.get_alerts() self.connection.send.has_been_called_with(b"") def test_get_alerts_with_trash(self): self.gmp.get_alerts(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_alerts(trash=False) self.connection.send.has_been_called_with(b'') def test_get_alerts_with_filter_string(self): self.gmp.get_alerts(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_alerts_with_filter_id(self): self.gmp.get_alerts(filter_id="f1") self.connection.send.has_been_called_with(b'') def test_get_alerts_with_tasks(self): self.gmp.get_alerts(tasks=True) self.connection.send.has_been_called_with(b'') self.gmp.get_alerts(tasks=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/alerts/test_modify_alert.py000066400000000000000000000162601466406635600275360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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( b'' ) 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( b'' b"lorem" b"" ) def test_modify_alert_with_name(self): self.gmp.modify_alert(alert_id="a1", name="lorem") self.connection.send.has_been_called_with( b'' b"lorem" b"" ) 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( b'' ) def test_modify_alert_invalid_condition(self): with self.assertRaises(InvalidArgument): 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(InvalidArgument): 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(InvalidArgument): 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(InvalidArgument): 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(InvalidArgument): 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( b'' b"Always" b"Email" b"Task run status changed" b"barfoo" b"" b"" ) 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( b'' b"Alwaysbarfoo" b"Email" b"Task run status changed" b"" ) 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( b'' b"Always" b"Emailbarfoo" b"Task run status changed" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/alerts/test_test_alert.py000066400000000000000000000010121466406635600272130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpTestAlertTestMixin: def test_test_alert(self): self.gmp.test_alert("a1") self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.test_alert(None) with self.assertRaises(GvmError): self.gmp.test_alert("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/alerts/test_trigger_alert.py000066400000000000000000000047741466406635600277210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 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( b'' ) 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( b'' ) 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( b'' ) 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( b'' ) def test_trigger_alert_with_report_format_type(self): self.gmp.trigger_alert( alert_id="a1", report_id="r1", report_format_id=ReportFormatType.SVG ) self.connection.send.has_been_called_with( b'' ) 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( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/audits/000077500000000000000000000000001466406635600234415ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/audits/__init__.py000066400000000000000000000015341466406635600255550ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneAuditTestMixin", "GmpCreateAuditTestMixin", "GmpDeleteAuditTestMixin", "GmpGetAuditTestMixin", "GmpGetAuditsTestMixin", "GmpModifyAuditTestMixin", "GmpResumeAuditTestMixin", "GmpStartAuditTestMixin", "GmpStopAuditTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/audits/test_clone_audit.py000066400000000000000000000010601466406635600273350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneAuditTestMixin: def test_clone(self): self.gmp.clone_audit("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/audits/test_create_audit.py000066400000000000000000000260041466406635600275050ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from collections import OrderedDict from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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( b"" b"foo" b"audit" b'' b'' b'' b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b"bar" b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b'' b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b'' b'' b'' b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b"1" b"" ) self.gmp.create_audit( name="foo", policy_id="c1", target_id="t1", scanner_id="s1", alterable=False, ) self.connection.send.has_been_called_with( b"" b"foo" b"audit" b'' b'' b'' b"0" b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b"reverse" b"" ) def test_create_audit_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgument): 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( b"" b"foo" b"audit" b'' b'' b'' b'' b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b'' b"0" b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b'' b"5" b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b"u1,u2" b"" ) 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( b"" b"foo" b"audit" b'' b'' b'' b"" b"" b"foo" b"bar" b"" b"" b"lorem" b"ipsum" b"" b"" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/audits/test_delete_audit.py000066400000000000000000000013511466406635600275020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteAuditTestMixin: def test_delete(self): self.gmp.delete_audit("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_audit("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_audit(None) with self.assertRaises(GvmError): self.gmp.delete_audit("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/audits/test_get_audit.py000066400000000000000000000010551466406635600270200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpGetAuditTestMixin: def test_get_audit(self): self.gmp.get_audit("a1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/audits/test_get_audits.py000066400000000000000000000031011466406635600271750ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetAuditsTestMixin: def test_get_audits_simple(self): self.gmp.get_audits() self.connection.send.has_been_called_with( b'' ) def test_get_audits_with_filter_string(self): self.gmp.get_audits(filter_string="name=foo") self.connection.send.has_been_called_with( b'' ) def test_get_audits_with_filter_id(self): self.gmp.get_audits(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_audits_from_trash(self): self.gmp.get_audits(trash=True) self.connection.send.has_been_called_with( b'' ) def test_get_audits_with_details(self): self.gmp.get_audits(details=True) self.connection.send.has_been_called_with( b'' ) def test_get_audits_without_details(self): self.gmp.get_audits(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_audits_with_schedules_only(self): self.gmp.get_audits(schedules_only=True) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/audits/test_modify_audit.py000066400000000000000000000135741466406635600275410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from collections import OrderedDict from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import HostsOrdering class GmpModifyAuditTestMixin: def test_modify_task(self): self.gmp.modify_audit("t1") self.connection.send.has_been_called_with( b'' ) 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( b'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( b'' ) 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( b'' ) 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( b'' ) 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( b'' ) def test_modify_audit_with_comment(self): self.gmp.modify_audit(audit_id="t1", comment="bar") self.connection.send.has_been_called_with( b'' b"bar" b"" ) 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( b'' b'' b'' b'' b"" ) 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( b'' ) def test_modify_audit_with_alterable(self): self.gmp.modify_audit(audit_id="t1", alterable=True) self.connection.send.has_been_called_with( b'' b"1" b"" ) self.gmp.modify_audit(audit_id="t1", alterable=False) self.connection.send.has_been_called_with( b'' b"0" b"" ) 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( b'' b"reverse" b"" ) def test_modify_audit_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgument): 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( b'' ) 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( b'' b"0" b"" ) self.gmp.modify_audit(audit_id="t1", schedule_periods=5) self.connection.send.has_been_called_with( b'' b"5" b"" ) 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( b'' b"u1,u2" b"" ) 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( b'' b"" b"" b"foo" b"bar" b"" b"" b"lorem" b"ipsum" b"" b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/audits/test_resume_audit.py000066400000000000000000000010241466406635600275350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpResumeAuditTestMixin: def test_resume_audit(self): self.gmp.resume_audit("a1") self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.resume_audit(None) with self.assertRaises(GvmError): self.gmp.resume_audit("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/audits/test_start_audit.py000066400000000000000000000007701466406635600274010ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpStartAuditTestMixin: def test_start_audit(self): self.gmp.start_audit("a1") self.connection.send.has_been_called_with(b'') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.start_audit(None) with self.assertRaises(GvmError): self.gmp.start_audit("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/audits/test_stop_audit.py000066400000000000000000000007621466406635600272320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpStopAuditTestMixin: def test_stop_audit(self): self.gmp.stop_audit("a1") self.connection.send.has_been_called_with(b'') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.stop_audit(None) with self.assertRaises(GvmError): self.gmp.stop_audit("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/credentials/000077500000000000000000000000001466406635600244455ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/credentials/__init__.py000066400000000000000000000012751466406635600265630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneCredentialTestMixin", "GmpCreateCredentialTestMixin", "GmpDeleteCredentialTestMixin", "GmpGetCredentialTestMixin", "GmpGetCredentialsTestMixin", "GmpModifyCredentialTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/credentials/test_clone_credential.py000066400000000000000000000011201466406635600313420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneCredentialTestMixin: def test_clone(self): self.gmp.clone_credential("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/credentials/test_create_credential.py000066400000000000000000000340441466406635600315200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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( b"" b"foo" b"up" b"bar" b"Max" b"123" b"" ) 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( b"" b"foo" b"up" b"bar" b"1" b"Max" b"123" b"" ) 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( b"" b"foo" b"up" b"bar" b"0" b"Max" b"123" b"" ) def test_create_up_credential_auto_generate_password(self): self.gmp.create_credential( name="foo", credential_type=CredentialType.USERNAME_PASSWORD, login="Max", ) self.connection.send.has_been_called_with( b"" b"foo" b"up" b"Max" b"" ) 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( b"" b"foo" b"cc" b"abcdef" b"" ) 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( b"" b"foo" b"cc" b"abcdef" b"" b"123456" b"" b"" ) 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", private_key="", ) 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( b"" b"foo" b"usk" b"foo" b"" b"123456" b"" b"" ) 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( b"" b"foo" b"usk" b"foo" b"" b"123456" b"abcdef" b"" b"" ) def test_create_usk_credential_auto_generate_ssh_key(self): self.gmp.create_credential( name="foo", credential_type=CredentialType.USERNAME_SSH_KEY, login="foo", ) self.connection.send.has_been_called_with( b"" b"foo" b"usk" b"foo" b"" ) def test_create_snmp_credential_invalid_auth_algorithm(self): with self.assertRaises(RequiredArgument): self.gmp.create_credential( name="foo", credential_type=CredentialType.SNMP, login="foo" ) with self.assertRaises(RequiredArgument): self.gmp.create_credential( name="foo", credential_type=CredentialType.SNMP, login="foo", auth_algorithm="", ) with self.assertRaises(InvalidArgument): 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( b"" b"foo" b"snmp" b"foo" b"md5" b"" ) 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( b"" b"foo" b"snmp" b"foo" b"sha1" b"" ) 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( b"" b"foo" b"snmp" b"foo" b"sha1" b"ipsum" b"" ) def test_create_snmp_credential_invalid_privacy_algorithm(self): with self.assertRaises(ValueError): self.gmp.create_credential( name="foo", credential_type=CredentialType.SNMP, login="foo", auth_algorithm=SnmpAuthAlgorithm.SHA1, privacy_algorithm="", ) with self.assertRaises(InvalidArgument): 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( b"" b"foo" b"snmp" b"foo" b"sha1" b"" b"aes" b"" b"" ) 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( b"" b"foo" b"snmp" b"foo" b"sha1" b"" b"des" b"" b"" ) 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( b"" b"foo" b"snmp" b"foo" b"sha1" b"" b"123" b"" b"" ) 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( b"" b"foo" b"smime" b"ipsum" b"" ) 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( b"" b"foo" b"pgp" b"" b"ipsum" b"" b"" ) 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(RequiredArgument): self.gmp.create_credential(name="foo", credential_type=None) with self.assertRaises(RequiredArgument): self.gmp.create_credential(name="foo", credential_type="") with self.assertRaises(InvalidArgument): 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( b"" b"foo" b"pw" b"foo" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/credentials/test_delete_credential.py000066400000000000000000000014451466406635600315160ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteCredentialTestMixin: def test_delete(self): self.gmp.delete_credential("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_credential("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/credentials/test_get_credential.py000066400000000000000000000055771466406635600310450ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import CredentialFormat class GmpGetCredentialTestMixin: def test_get_credential(self): self.gmp.get_credential("id") self.connection.send.has_been_called_with( b'' ) 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( b'' ) self.gmp.get_credential("id", credential_format=CredentialFormat.RPM) self.connection.send.has_been_called_with( b'' ) self.gmp.get_credential("id", credential_format=CredentialFormat.DEB) self.connection.send.has_been_called_with( b'' ) self.gmp.get_credential("id", credential_format=CredentialFormat.EXE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_credential("id", credential_format=CredentialFormat.PEM) self.connection.send.has_been_called_with( b'' ) def test_get_credential_with_invalid_credential_format(self): with self.assertRaises(InvalidArgument): 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( b'' ) self.gmp.get_credential("id", scanners=False) self.connection.send.has_been_called_with( b'' ) def test_get_credential_with_targets(self): self.gmp.get_credential("id", targets=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_credential("id", targets=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/credentials/test_get_credentials.py000066400000000000000000000034041466406635600312130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetCredentialsTestMixin: def test_get_credentials(self): self.gmp.get_credentials() self.connection.send.has_been_called_with(b"") def test_get_credentials_with_filter_string(self): self.gmp.get_credentials(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_credentials_with_filter_id(self): self.gmp.get_credentials(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_credentials_with_scanners(self): self.gmp.get_credentials(scanners=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_credentials(scanners=False) self.connection.send.has_been_called_with( b'' ) def test_get_credentials_with_trash(self): self.gmp.get_credentials(trash=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_credentials(trash=False) self.connection.send.has_been_called_with( b'' ) def test_get_credentials_with_targets(self): self.gmp.get_credentials(targets=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_credentials(targets=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/credentials/test_modify_credential.py000066400000000000000000000155031466406635600315430ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import ( SnmpAuthAlgorithm, SnmpPrivacyAlgorithm, ) class GmpModifyCredentialTestMixin: def test_modify_credential(self): self.gmp.modify_credential(credential_id="c1") self.connection.send.has_been_called_with( b'' ) 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( b'' b"foo" b"" ) def test_modify_credential_with_comment(self): self.gmp.modify_credential(credential_id="c1", comment="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) def test_modify_credential_with_certificate(self): self.gmp.modify_credential(credential_id="c1", certificate="abcdef") self.connection.send.has_been_called_with( b'' b"abcdef" b"" ) 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( b'' b"" b"foo" b"123456" b"" b"" ) 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( b'' b"1" b"" ) self.gmp.modify_credential(credential_id="c1", allow_insecure=False) self.connection.send.has_been_called_with( b'' b"0" b"" ) def test_modify_credential_with_login(self): self.gmp.modify_credential(credential_id="c1", login="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) def test_modify_credential_with_password(self): self.gmp.modify_credential(credential_id="c1", password="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) 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( b'' b"md5" b"" ) self.gmp.modify_credential( credential_id="c1", auth_algorithm=SnmpAuthAlgorithm.SHA1 ) self.connection.send.has_been_called_with( b'' b"sha1" b"" ) def test_modify_credential_invalid_auth_algorithm(self): with self.assertRaises(InvalidArgument): 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( b'' b"foo" b"" ) 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( b'' b"" b"aes" b"" b"" ) self.gmp.modify_credential( credential_id="c1", privacy_algorithm=SnmpPrivacyAlgorithm.DES ) self.connection.send.has_been_called_with( b'' b"" b"des" b"" b"" ) def test_modify_credential_invalid_privacy_algorithm(self): with self.assertRaises(ValueError): self.gmp.modify_credential(credential_id="c1", privacy_algorithm="") with self.assertRaises(InvalidArgument): 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( b'' b"" b"foo" b"" b"" ) 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( b'' b"" b"foo" b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/filters/000077500000000000000000000000001466406635600236205ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/filters/__init__.py000066400000000000000000000011651466406635600257340ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneFilterTestMixin", "GmpCreateFilterTestMixin", "GmpDeleteFilterTestMixin", "GmpGetFilterTestMixin", "GmpGetFiltersTestMixin", "GmpModifyFilterTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/filters/test_clone_filter.py000066400000000000000000000010701466406635600276740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneFilterTestMixin: def test_clone(self): self.gmp.clone_filter("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/filters/test_create_filter.py000066400000000000000000000066221466406635600300470ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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}" "".encode("utf-8") ) def test_create_filter_invalid_filter_type(self): with self.assertRaises(InvalidArgument): 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( b"" b"f1" b"foo" b"sort-reverse=threat result_hosts_only=1 notes=1 " b"overrides=1 levels=hml first=1 rows=1000" b"" ) 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( b"" b"f1" b"foo" b"sort-reverse=threat result_hosts_only=1 notes=1 " b"overrides=1 levels=hml first=1 rows=1000" b"task" b"" ) 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( b"" b"f1" b"foo" b"task" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/filters/test_delete_filter.py000066400000000000000000000013751466406635600300460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteFilterTestMixin: def test_delete(self): self.gmp.delete_filter("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_filter("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/filters/test_get_filter.py000066400000000000000000000021441466406635600273560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetFilterTestMixin: def test_get_filter(self): self.gmp.get_filter("f1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_filter(filter_id="f1") self.connection.send.has_been_called_with( b'' ) 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( b'' ) self.gmp.get_filter(filter_id="f1", alerts=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/filters/test_get_filters.py000066400000000000000000000023501466406635600275400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetFiltersTestMixin: def test_get_filters(self): self.gmp.get_filters() self.connection.send.has_been_called_with(b"") def test_get_filters_with_filter_string(self): self.gmp.get_filters(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_filters_with_filter_id(self): self.gmp.get_filters(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_filters_with_trash(self): self.gmp.get_filters(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_filters(trash=False) self.connection.send.has_been_called_with(b'') def test_get_filters_with_alerts(self): self.gmp.get_filters(alerts=True) self.connection.send.has_been_called_with(b'') self.gmp.get_filters(alerts=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/filters/test_modify_filter.py000066400000000000000000000040651466406635600300720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import FilterType class GmpModifyFilterTestMixin: def test_modify_filter(self): self.gmp.modify_filter(filter_id="f1") self.connection.send.has_been_called_with( b'' ) 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( b'' b"task" b"" ) def test_modify_filter_invalid_filter_type(self): with self.assertRaises(InvalidArgument): 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( b'' b"foo" b"" ) def test_modify_filter_with_name(self): self.gmp.modify_filter(filter_id="f1", name="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) def test_modify_filter_with_term(self): self.gmp.modify_filter(filter_id="f1", term="foo=bar") self.connection.send.has_been_called_with( b'' b"foo=bar" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/groups/000077500000000000000000000000001466406635600234675ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/groups/__init__.py000066400000000000000000000011431466406635600255770ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneGroupTestMixin", "GmpCreateGroupTestMixin", "GmpDeleteGroupTestMixin", "GmpGetGroupTestMixin", "GmpGetGroupsTestMixin", "GmpModifyGroupTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/groups/test_clone_group.py000066400000000000000000000010621466406635600274130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneGroupTestMixin: def test_clone(self): self.gmp.clone_group("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/groups/test_create_group.py000066400000000000000000000032221466406635600275560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"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( b"" b"foo" b"bar" b"" ) def test_create_special_group(self): self.gmp.create_group(name="foo", special=True) self.connection.send.has_been_called_with( b"" b"foo" b"" b"" b"" b"" ) def test_create_group_with_users(self): self.gmp.create_group(name="foo", users=[]) self.connection.send.has_been_called_with( b"foo" ) self.gmp.create_group(name="foo", users=["u1", "u2"]) self.connection.send.has_been_called_with( b"" b"foo" b"u1,u2" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/groups/test_delete_group.py000066400000000000000000000013631466406635600275610ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteGroupTestMixin: def test_delete(self): self.gmp.delete_group("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_group("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/groups/test_get_group.py000066400000000000000000000013121466406635600270700ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetGroupTestMixin: def test_get_group(self): self.gmp.get_group("f1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_group(group_id="f1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/groups/test_get_groups.py000066400000000000000000000016361466406635600272640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetGroupsTestMixin: def test_get_groups(self): self.gmp.get_groups() self.connection.send.has_been_called_with(b"") def test_get_groups_with_filter_string(self): self.gmp.get_groups(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_groups_with_filter_id(self): self.gmp.get_groups(filter_id="f1") self.connection.send.has_been_called_with(b'') def test_get_groups_with_trash(self): self.gmp.get_groups(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_groups(trash=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/groups/test_modify_group.py000066400000000000000000000033041466406635600276030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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( b'' b"foo" b"" ) def test_modify_group_with_name(self): self.gmp.modify_group(group_id="f1", name="foo") self.connection.send.has_been_called_with( b'foo' ) def test_modify_group_with_users(self): self.gmp.modify_group(group_id="f1", users=["foo"]) self.connection.send.has_been_called_with( b'' b"foo" b"" ) self.gmp.modify_group(group_id="f1", users=["foo", "bar"]) self.connection.send.has_been_called_with( b'' b"foo,bar" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/hosts/000077500000000000000000000000001466406635600233105ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/hosts/__init__.py000066400000000000000000000010011466406635600254110ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCreateHostTestMixin", "GmpDeleteHostTestMixin", "GmpGetHostTestMixin", "GmpGetHostsTestMixin", "GmpModifyHostTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/hosts/test_create_host.py000066400000000000000000000021051466406635600272170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"" b"" b"host" b"ipsum" b"" b"" ) def test_create_asset_with_comment(self): self.gmp.create_host(name="ipsum", comment="lorem") self.connection.send.has_been_called_with( b"" b"" b"host" b"ipsum" b"lorem" b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/hosts/test_delete_host.py000066400000000000000000000007201466406635600272170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) def test_missing_arguments(self): with self.assertRaises(GvmError): self.gmp.delete_host(None) python-gvm-24.8.0/tests/protocols/gmpv224/entities/hosts/test_get_host.py000066400000000000000000000022441466406635600265370ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetHostTestMixin: def test_get_host(self): self.gmp.get_host("a1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_host(host_id="a1") self.connection.send.has_been_called_with( b'' ) def test_get_host_details(self): self.gmp.get_host("a1", details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_host("a1", details=False) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/hosts/test_get_hosts.py000066400000000000000000000020271466406635600267210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetHostsTestMixin: def test_get_hosts(self): self.gmp.get_hosts() self.connection.send.has_been_called_with(b'') def test_get_hosts_details(self): self.gmp.get_hosts(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_hosts(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_hosts_with_filter_string(self): self.gmp.get_hosts(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_hosts_with_filter_id(self): self.gmp.get_hosts(filter_id="f1") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/hosts/test_modify_host.py000066400000000000000000000033031466406635600272440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"" b"" ) 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( b'' b"foo" b"" ) self.gmp.modify_host("a1", comment="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) self.gmp.modify_host("a1", comment="") self.connection.send.has_been_called_with( b'' b"" b"" ) self.gmp.modify_host("a1", comment=None) self.connection.send.has_been_called_with( b'' b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/notes/000077500000000000000000000000001466406635600233005ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/notes/__init__.py000066400000000000000000000011211466406635600254040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneNoteTestMixin", "GmpCreateNoteTestMixin", "GmpDeleteNoteTestMixin", "GmpGetNoteTestMixin", "GmpGetNotesTestMixin", "GmpModifyNoteTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/notes/test_clone_note.py000066400000000000000000000010541466406635600270360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneNoteTestMixin: def test_clone(self): self.gmp.clone_note("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/notes/test_create_note.py000066400000000000000000000111411466406635600271770ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from decimal import Decimal from gvm.errors import InvalidArgument, RequiredArgument class GmpCreateNoteTestMixin: def test_create_note(self): self.gmp.create_note("foo", nvt_oid="oid1") self.connection.send.has_been_called_with( b"" b"foo" b'' b"" ) 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( b"" b"foo" b'' b"" ) self.gmp.create_note("foo", nvt_oid="oid1", hosts=["h1", "h2"]) self.connection.send.has_been_called_with( b"" b"foo" b'' b"h1,h2" b"" ) def test_create_note_with_port(self): self.gmp.create_note("foo", nvt_oid="oid1", port="666/tcp") self.connection.send.has_been_called_with( b"" b"foo" b'' b"666/tcp" b"" ) 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( b"" b"foo" b'' b'' b"" ) 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( b"" b"foo" b'' b'' b"" ) 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( b"" b"foo" b'' b"5.5" b"" ) self.gmp.create_note("foo", nvt_oid="oid1", severity=5.5) self.connection.send.has_been_called_with( b"" b"foo" b'' b"5.5" b"" ) self.gmp.create_note("foo", nvt_oid="oid1", severity=Decimal(5.5)) self.connection.send.has_been_called_with( b"" b"foo" b'' b"5.5" b"" ) 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( b"" b"foo" b'' b"0" b"" ) self.gmp.create_note("foo", nvt_oid="oid1", days_active=-1) self.connection.send.has_been_called_with( b"" b"foo" b'' b"-1" b"" ) self.gmp.create_note("foo", nvt_oid="oid1", days_active=3600) self.connection.send.has_been_called_with( b"" b"foo" b'' b"3600" b"" ) def test_create_note_with_invalid_port(self): with self.assertRaises(InvalidArgument): self.gmp.create_note(text="foo", nvt_oid="oid1", port="123") with self.assertRaises(InvalidArgument): self.gmp.create_note(text="foo", nvt_oid="oid1", port="tcp/123") python-gvm-24.8.0/tests/protocols/gmpv224/entities/notes/test_delete_note.py000066400000000000000000000013441466406635600272020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteNoteTestMixin: def test_delete(self): self.gmp.delete_note("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_note("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_note(None) with self.assertRaises(GvmError): self.gmp.delete_note("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/notes/test_get_note.py000066400000000000000000000013241466406635600265150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetNoteTestMixin: def test_get_note(self): self.gmp.get_note("n1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_note(note_id="n1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/notes/test_get_notes.py000066400000000000000000000022641466406635600267040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetNotesTestMixin: def test_get_notes(self): self.gmp.get_notes() self.connection.send.has_been_called_with(b"") def test_get_notes_with_filter_string(self): self.gmp.get_notes(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_notes_with_filter_id(self): self.gmp.get_notes(filter_id="f1") self.connection.send.has_been_called_with(b'') def test_get_notes_with_details(self): self.gmp.get_notes(details=True) self.connection.send.has_been_called_with(b'') self.gmp.get_notes(details=False) self.connection.send.has_been_called_with(b'') def test_get_notes_with_result(self): self.gmp.get_notes(result=True) self.connection.send.has_been_called_with(b'') self.gmp.get_notes(result=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/notes/test_modify_note.py000066400000000000000000000112151466406635600272250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from decimal import Decimal from gvm.errors import InvalidArgument, RequiredArgument class GmpModifyNoteTestMixin: def test_modify_note(self): self.gmp.modify_note(note_id="n1", text="foo") self.connection.send.has_been_called_with( b'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( b'' b"foo" b"0" b"" ) self.gmp.modify_note(note_id="n1", text="foo", days_active=-1) self.connection.send.has_been_called_with( b'' b"foo" b"-1" b"" ) self.gmp.modify_note(note_id="n1", text="foo", days_active=600) self.connection.send.has_been_called_with( b'' b"foo" b"600" b"" ) def test_modify_note_with_port(self): self.gmp.modify_note(note_id="n1", text="foo", port="123/tcp") self.connection.send.has_been_called_with( b'' b"foo" b"123/tcp" b"" ) 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( b'' b"foo" b"foo" b"" ) self.gmp.modify_note(note_id="n1", text="foo", hosts=["foo", "bar"]) self.connection.send.has_been_called_with( b'' b"foo" b"foo,bar" b"" ) 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( b'' b"foo" b'' b"" ) 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( b'' b"foo" b'' b"" ) 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( b'' b"foo" b"5.5" b"" ) self.gmp.modify_note(note_id="n1", text="foo", severity=5.5) self.connection.send.has_been_called_with( b'' b"foo" b"5.5" b"" ) self.gmp.modify_note(note_id="n1", text="foo", severity=Decimal(5.5)) self.connection.send.has_been_called_with( b'' b"foo" b"5.5" b"" ) def test_modify_note_with_invalid_port(self): with self.assertRaises(InvalidArgument): self.gmp.modify_note(note_id="o1", text="foo", port="123") with self.assertRaises(InvalidArgument): self.gmp.modify_note(note_id="o1", text="foo", port="tcp/123") python-gvm-24.8.0/tests/protocols/gmpv224/entities/operating_systems/000077500000000000000000000000001466406635600257275ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/operating_systems/__init__.py000066400000000000000000000010661466406635600300430ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpDeleteOperatingSystemTestMixin", "GmpGetOperatingSystemTestMixin", "GmpGetOperatingSystemsTestMixin", "GmpModifyOperatingSystemTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/operating_systems/test_delete_operating_system.py000066400000000000000000000010131466406635600342510ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) def test_missing_arguments(self): with self.assertRaises(GvmError): self.gmp.delete_operating_system(None) python-gvm-24.8.0/tests/protocols/gmpv224/entities/operating_systems/test_get_operating_system.py000066400000000000000000000023701466406635600335750ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) self.gmp.get_operating_system(operating_system_id="a1") self.connection.send.has_been_called_with( b'' ) def test_get_operating_system_details(self): self.gmp.get_operating_system("a1", details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_operating_system("a1", details=False) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/operating_systems/test_get_operating_systems.py000066400000000000000000000022041466406635600337540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetOperatingSystemsTestMixin: def test_get_operating_systems(self): self.gmp.get_operating_systems() self.connection.send.has_been_called_with(b'') def test_get_operating_systems_details(self): self.gmp.get_operating_systems(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_operating_systems(details=False) self.connection.send.has_been_called_with( b'' ) 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( b'' ) def test_get_operating_systems_with_filter_id(self): self.gmp.get_operating_systems(filter_id="f1") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/operating_systems/test_modify_operating_system.py000066400000000000000000000036761466406635600343170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"" b"" ) 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( b'' b"foo" b"" ) self.gmp.modify_operating_system("a1", comment="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) self.gmp.modify_operating_system("a1", comment="") self.connection.send.has_been_called_with( b'' b"" b"" ) self.gmp.modify_operating_system("a1", comment=None) self.connection.send.has_been_called_with( b'' b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/overrides/000077500000000000000000000000001466406635600241525ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/overrides/__init__.py000066400000000000000000000012311466406635600262600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneOverrideTestMixin", "GmpCreateOverrideTestMixin", "GmpDeleteOverrideTestMixin", "GmpGetOverrideTestMixin", "GmpGetOverridesTestMixin", "GmpModifyOverrideTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/overrides/test_clone_override.py000066400000000000000000000011041466406635600305560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneOverrideTestMixin: def test_clone(self): self.gmp.clone_override("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/overrides/test_create_override.py000066400000000000000000000135031466406635600307270ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from decimal import Decimal from gvm.errors import InvalidArgument, RequiredArgument class GmpCreateOverrideTestMixin: def test_create_override(self): self.gmp.create_override("foo", nvt_oid="oid1") self.connection.send.has_been_called_with( b"" b"foo" b'' b"" ) 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( b"" b"foo" b'' b"" ) self.gmp.create_override("foo", nvt_oid="oid1", hosts=["h1", "h2"]) self.connection.send.has_been_called_with( b"" b"foo" b'' b"h1,h2" b"" ) def test_create_override_with_port(self): self.gmp.create_override("foo", nvt_oid="oid1", port="666/udp") self.connection.send.has_been_called_with( b"" b"foo" b'' b"666/udp" b"" ) 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( b"" b"foo" b'' b'' b"" ) 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( b"" b"foo" b'' b'' b"" ) 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( b"" b"foo" b'' b"5.5" b"" ) self.gmp.create_override("foo", nvt_oid="oid1", severity=5.5) self.connection.send.has_been_called_with( b"" b"foo" b'' b"5.5" b"" ) self.gmp.create_override("foo", nvt_oid="oid1", severity=Decimal(5.5)) self.connection.send.has_been_called_with( b"" b"foo" b'' b"5.5" b"" ) 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( b"" b"foo" b'' b"5.5" b"" ) self.gmp.create_override("foo", nvt_oid="oid1", new_severity=5.5) self.connection.send.has_been_called_with( b"" b"foo" b'' b"5.5" b"" ) self.gmp.create_override( "foo", nvt_oid="oid1", new_severity=Decimal(5.5) ) self.connection.send.has_been_called_with( b"" b"foo" b'' b"5.5" b"" ) 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( b"" b"foo" b'' b"0" b"" ) self.gmp.create_override("foo", nvt_oid="oid1", days_active=-1) self.connection.send.has_been_called_with( b"" b"foo" b'' b"-1" b"" ) self.gmp.create_override("foo", nvt_oid="oid1", days_active=3600) self.connection.send.has_been_called_with( b"" b"foo" b'' b"3600" b"" ) def test_create_override_with_invalid_port(self): with self.assertRaises(InvalidArgument): self.gmp.create_override(text="foo", nvt_oid="oid1", port="123") with self.assertRaises(InvalidArgument): self.gmp.create_override(text="foo", nvt_oid="oid1", port="tcp/123") python-gvm-24.8.0/tests/protocols/gmpv224/entities/overrides/test_delete_override.py000066400000000000000000000014101466406635600307200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteOverrideTestMixin: def test_delete(self): self.gmp.delete_override("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_override("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_override(None) with self.assertRaises(GvmError): self.gmp.delete_override("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/overrides/test_get_override.py000066400000000000000000000014141466406635600302410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetOverrideTestMixin: def test_get_override(self): self.gmp.get_override("o1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_override(override_id="o1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/overrides/test_get_overrides.py000066400000000000000000000025621466406635600304310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetOverridesTestMixin: def test_get_overrides(self): self.gmp.get_overrides() self.connection.send.has_been_called_with(b"") def test_get_overrides_with_filter_string(self): self.gmp.get_overrides(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_overrides_with_filter_id(self): self.gmp.get_overrides(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_overrides_with_details(self): self.gmp.get_overrides(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_overrides(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_overrides_with_result(self): self.gmp.get_overrides(result=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_overrides(result=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/overrides/test_modify_override.py000066400000000000000000000136651466406635600307640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from decimal import Decimal from gvm.errors import InvalidArgument, RequiredArgument class GmpModifyOverrideTestMixin: def test_modify_override(self): self.gmp.modify_override(override_id="o1", text="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) 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( b'' b"foo" b"0" b"" ) self.gmp.modify_override(override_id="o1", text="foo", days_active=-1) self.connection.send.has_been_called_with( b'' b"foo" b"-1" b"" ) self.gmp.modify_override(override_id="o1", text="foo", days_active=600) self.connection.send.has_been_called_with( b'' b"foo" b"600" b"" ) def test_modify_override_with_port(self): self.gmp.modify_override(override_id="o1", text="foo", port="123/udp") self.connection.send.has_been_called_with( b'' b"foo" b"123/udp" b"" ) 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( b'' b"foo" b"foo" b"" ) self.gmp.modify_override( override_id="o1", text="foo", hosts=["foo", "bar"] ) self.connection.send.has_been_called_with( b'' b"foo" b"foo,bar" b"" ) 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( b'' b"foo" b'' b"" ) 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( b'' b"foo" b'' b"" ) 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( b'' b"foo" b"5.5" b"" ) self.gmp.modify_override(override_id="o1", text="foo", severity=5.5) self.connection.send.has_been_called_with( b'' b"foo" b"5.5" b"" ) self.gmp.modify_override( override_id="o1", text="foo", severity=Decimal(5.5) ) self.connection.send.has_been_called_with( b'' b"foo" b"5.5" b"" ) 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( b'' b"foo" b"5.5" b"" ) self.gmp.modify_override(override_id="o1", text="foo", new_severity=5.5) self.connection.send.has_been_called_with( b'' b"foo" b"5.5" b"" ) self.gmp.modify_override( override_id="o1", text="foo", new_severity=Decimal(5.5) ) self.connection.send.has_been_called_with( b'' b"foo" b"5.5" b"" ) def test_modify_override_with_invalid_port(self): with self.assertRaises(InvalidArgument): self.gmp.modify_override(override_id="o1", text="foo", port="123") python-gvm-24.8.0/tests/protocols/gmpv224/entities/permissions/000077500000000000000000000000001466406635600245235ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/permissions/__init__.py000066400000000000000000000012751466406635600266410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpClonePermissionTestMixin", "GmpCreatePermissionTestMixin", "GmpDeletePermissionTestMixin", "GmpGetPermissionTestMixin", "GmpGetPermissionsTestMixin", "GmpModifyPermissionTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/permissions/test_clone_permission.py000066400000000000000000000011201466406635600314760ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpClonePermissionTestMixin: def test_clone(self): self.gmp.clone_permission("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/permissions/test_create_permission.py000066400000000000000000000130361466406635600316520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import EntityType, PermissionSubjectType 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( b"" b"foo" b'' b"user" b"" b"" ) 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(ValueError): self.gmp.create_permission( "create_task", subject_id="u1", subject_type="" ) with self.assertRaises(ValueError): self.gmp.create_permission( "create_task", subject_id="u1", subject_type=None ) with self.assertRaises(InvalidArgument): 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( b"" b"create_task" b'' b"user" b"" b"foo" b"" ) 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(InvalidArgument): 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( b"" b"create_task" b'' b"user" b"" b'' b"task" b"" b"" ) 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( b"" b"create_task" b'' b"user" b"" b'' b"task" b"" b"" ) 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( b"" b"create_task" b'' b"user" b"" b'' b"config" b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/permissions/test_delete_permission.py000066400000000000000000000014321466406635600316460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeletePermissionTestMixin: def test_delete(self): self.gmp.delete_permission("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_permission("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_permission(None) with self.assertRaises(GvmError): self.gmp.delete_permission("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/permissions/test_get_permission.py000066400000000000000000000014201466406635600311600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetPermissionTestMixin: def test_get_permission(self): self.gmp.get_permission("p1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_permission(permission_id="p1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/permissions/test_get_permissions.py000066400000000000000000000020531466406635600313460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetPermissionsTestMixin: def test_get_permissions(self): self.gmp.get_permissions() self.connection.send.has_been_called_with(b"") def test_get_permissions_with_filter_string(self): self.gmp.get_permissions(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_permissions_with_filter_id(self): self.gmp.get_permissions(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_permissions_with_trash(self): self.gmp.get_permissions(trash=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_permissions(trash=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/permissions/test_modify_permission.py000066400000000000000000000153011466406635600316730ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import EntityType, PermissionSubjectType class GmpModifyPermissionTestMixin: def test_modify_permission(self): self.gmp.modify_permission(permission_id="p1") self.connection.send.has_been_called_with( b'' ) 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( b'' b"foo" b"" ) 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( b'' b'' b"task" b"" b"" ) 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( b'' b'' b"task" b"" b"" ) 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( b'' b'' b"config" b"" b"" ) 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(InvalidArgument): 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( b'' b'' b"role" b"" b"" ) self.gmp.modify_permission( permission_id="p1", subject_id="s1", subject_type=PermissionSubjectType.USER, ) self.connection.send.has_been_called_with( b'' b'' b"user" b"" b"" ) self.gmp.modify_permission( permission_id="p1", subject_id="s1", subject_type=PermissionSubjectType.GROUP, ) self.connection.send.has_been_called_with( b'' b'' b"group" b"" b"" ) 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(InvalidArgument): self.gmp.modify_permission( permission_id="p1", subject_id="s1", subject_type="foo" ) with self.assertRaises(RequiredArgument): self.gmp.modify_permission( permission_id="p1", subject_id="s1", subject_type="" ) with self.assertRaises(RequiredArgument): 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( b'' b"foo" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/policies/000077500000000000000000000000001466406635600237575ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/policies/__init__.py000066400000000000000000000027041466406635600260730ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_clone_policy import GmpClonePolicyTestMixin from .test_create_policy import GmpCreatePolicyTestMixin from .test_delete_policy import GmpDeletePolicyTestMixin from .test_get_policies import GmpGetPoliciesTestMixin from .test_get_policy import GmpGetPolicyTestMixin 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, ) __all__ = ( "GmpClonePolicyTestMixin", "GmpCreatePolicyTestMixin", "GmpDeletePolicyTestMixin", "GmpGetPoliciesTestMixin", "GmpGetPolicyTestMixin", "GmpImportPolicyTestMixin", "GmpModifyPolicySetCommentTestMixin", "GmpModifyPolicySetFamilySelectionTestMixin", "GmpModifyPolicySetNameTestMixin", "GmpModifyPolicySetNvtPreferenceTestMixin", "GmpModifyPolicySetNvtSelectionTestMixin", "GmpModifyPolicySetScannerPreferenceTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/policies/test_clone_policy.py000066400000000000000000000010701466406635600300450ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpClonePolicyTestMixin: def test_clone(self): self.gmp.clone_policy("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/policies/test_create_policy.py000066400000000000000000000022171466406635600302140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCreatePolicyTestMixin: def test_create_policy(self): self.gmp.create_policy("foo") self.connection.send.has_been_called_with( b"" b"085569ce-73ed-11df-83c3-002264764cea" b"foo" b"policy" b"" ) 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( b"" b"foo" b"p1" b"foo" b"policy" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/policies/test_delete_policy.py000066400000000000000000000013751466406635600302170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeletePolicyTestMixin: def test_delete(self): self.gmp.delete_policy("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_policy("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/policies/test_get_policies.py000066400000000000000000000052641466406635600300450ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetPoliciesTestMixin: def test_get_policies_simple(self): self.gmp.get_policies() self.connection.send.has_been_called_with( b'' ) def test_get_policies_with_filter_string(self): self.gmp.get_policies(filter_string="name=foo") self.connection.send.has_been_called_with( b'' ) def test_get_policies_with_filter_id(self): self.gmp.get_policies(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_policies_from_trash(self): self.gmp.get_policies(trash=True) self.connection.send.has_been_called_with( b'' ) def test_get_policies_with_details(self): self.gmp.get_policies(details=True) self.connection.send.has_been_called_with( b'' ) def test_get_policies_without_details(self): self.gmp.get_policies(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_policies_with_families(self): self.gmp.get_policies(families=True) self.connection.send.has_been_called_with( b'' ) def test_get_policies_without_families(self): self.gmp.get_policies(families=False) self.connection.send.has_been_called_with( b'' ) def test_get_policies_with_preferences(self): self.gmp.get_policies(preferences=True) self.connection.send.has_been_called_with( b'' ) def test_get_policies_without_preferences(self): self.gmp.get_policies(preferences=False) self.connection.send.has_been_called_with( b'' ) def test_get_policies_with_audits(self): self.gmp.get_policies(audits=True) self.connection.send.has_been_called_with( b'' ) def test_get_policies_without_audits(self): self.gmp.get_policies(audits=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/policies/test_get_policy.py000066400000000000000000000014701466406635600275300ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpGetPolicyTestMixin: def test_get_policy(self): self.gmp.get_policy("a1") self.connection.send.has_been_called_with( b'' ) def test_get_policy_with_audits(self): self.gmp.get_policy("a1", audits=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/policies/test_import_policy.py000066400000000000000000000023231466406635600302610ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument 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}".encode( "utf-8" ) ) 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-24.8.0/tests/protocols/gmpv224/entities/policies/test_modify_policy_set_comment.py000066400000000000000000000024561466406635600326420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"" b"" ) self.gmp.modify_policy_set_comment("c1", comment="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) self.gmp.modify_policy_set_comment("c1", comment=None) self.connection.send.has_been_called_with( b'' b"" b"" ) 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.py000066400000000000000000000135641466406635600344510ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/policies# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"" ) self.gmp.modify_policy_set_family_selection( policy_id="c1", families=(("foo", True, True), ("bar", True, True)) ) self.connection.send.has_been_called_with( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"bar" b"1" b"1" b"" b"" b"" ) self.gmp.modify_policy_set_family_selection( policy_id="c1", families=[("foo", True, False), ("bar", False, True)], ) self.connection.send.has_been_called_with( b'' b"" b"1" b"" b"foo" b"0" b"1" b"" b"" b"bar" b"1" b"0" b"" b"" b"" ) 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(RequiredArgument): self.gmp.modify_policy_set_family_selection( policy_id="c1", families=None ) 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"" ) 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( b'' b"" b"0" b"" b"foo" b"1" b"1" b"" b"" b"" ) 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"" ) self.gmp.modify_policy_set_family_selection( policy_id="c1", families=[("foo", False, True)] ) self.connection.send.has_been_called_with( b'' b"" b"1" b"" b"foo" b"1" b"0" b"" b"" b"" ) self.gmp.modify_policy_set_family_selection( policy_id="c1", families=[("foo", False, True), ("bar", True, False)], ) self.connection.send.has_been_called_with( b'' b"" b"1" b"" b"foo" b"1" b"0" b"" b"" b"bar" b"0" b"1" b"" b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/policies/test_modify_policy_set_name.py000066400000000000000000000023621466406635600321140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"foo" b"" ) 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", "") python-gvm-24.8.0/tests/protocols/gmpv224/entities/policies/test_modify_policy_set_nvt_preference.py000066400000000000000000000060371466406635600342040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"" b'' b"foo" b"" b"" ) self.gmp.modify_policy_set_nvt_preference("c1", "foo", "o1") self.connection.send.has_been_called_with( b'' b"" b'' b"foo" b"" b"" ) 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( b'' b"" b'' b"foo" b"YmFy" b"" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/policies/test_modify_policy_set_nvt_selection.py000066400000000000000000000066221466406635600340530ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument 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( b'' b"" b"foo" b'' b"" b"" ) self.gmp.modify_policy_set_nvt_selection( policy_id="c1", family="foo", nvt_oids=["o1", "o2"] ) self.connection.send.has_been_called_with( b'' b"" b"foo" b'' b'' b"" b"" ) self.gmp.modify_policy_set_nvt_selection("c1", "foo", ["o1"]) self.connection.send.has_been_called_with( b'' b"" b"foo" b'' b"" b"" ) self.gmp.modify_policy_set_nvt_selection("c1", "foo", ("o1", "o2")) self.connection.send.has_been_called_with( b'' b"" b"foo" b'' b'' b"" b"" ) self.gmp.modify_policy_set_nvt_selection( policy_id="c1", family="foo", nvt_oids=[] ) self.connection.send.has_been_called_with( b'' b"" b"foo" b"" b"" ) 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(RequiredArgument): self.gmp.modify_policy_set_nvt_selection( policy_id="c1", family="foo", nvt_oids=None ) test_modify_policy_set_scanner_preference.py000066400000000000000000000044241466406635600347450ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/policies# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"" b"foo" b"" b"" ) self.gmp.modify_policy_set_scanner_preference("c1", "foo") self.connection.send.has_been_called_with( b'' b"" b"foo" b"" b"" ) 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( b'' b"" b"foo" b"YmFy" b"" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/port_lists/000077500000000000000000000000001466406635600243525ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/port_lists/__init__.py000066400000000000000000000015451466406635600264700ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpClonePortListTestMixin", "GmpCreatePortListTestMixin", "GmpCreatePortRangeTestMixin", "GmpDeletePortListTestMixin", "GmpDeletePortRangeTestMixin", "GmpGetPortListTestMixin", "GmpGetPortListsTestMixin", "GmpModifyPortListTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/port_lists/test_clone_port_list.py000066400000000000000000000011111466406635600311540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpClonePortListTestMixin: def test_clone(self): self.gmp.clone_port_list("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/port_lists/test_create_port_list.py000066400000000000000000000027171466406635600313340ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"" b"foo" b"T:1-1234" b"" ) 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( b"" b"foo" b"T:1-1234" b"lorem" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/port_lists/test_create_port_range.py000066400000000000000000000105171466406635600314520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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(InvalidArgument): 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( b"" b'' b"1" b"1234" b"TCP" b"" ) 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( b"" b'' b"1" b"1234" b"UDP" b"" ) 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( b"" b'' b"1" b"1234" b"TCP" b"" ) 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( b"" b'' b"1" b"1234" b"TCP" b"lorem" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/port_lists/test_delete_port_list.py000066400000000000000000000014201466406635600313210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeletePortListTestMixin: def test_delete(self): self.gmp.delete_port_list("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_port_list("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/port_lists/test_delete_port_range.py000066400000000000000000000010551466406635600314460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeletePortRangeTestMixin: def test_delete(self): self.gmp.delete_port_range("a1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/port_lists/test_get_port_list.py000066400000000000000000000013611466406635600306420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/port_lists/test_get_port_lists.py000066400000000000000000000033451466406635600310310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetPortListsTestMixin: def test_get_port_lists(self): self.gmp.get_port_lists() self.connection.send.has_been_called_with(b"") 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( b'' ) def test_get_port_lists_with_filter_id(self): self.gmp.get_port_lists(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_port_lists_with_trash(self): self.gmp.get_port_lists(trash=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_port_lists(trash=False) self.connection.send.has_been_called_with( b'' ) def test_get_port_lists_with_details(self): self.gmp.get_port_lists(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_port_lists(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_port_lists_with_targets(self): self.gmp.get_port_lists(targets=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_port_lists(targets=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/port_lists/test_modify_port_list.py000066400000000000000000000025001466406635600313460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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( b'' b"foo" b"" ) 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( b'' b"foo" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/report_formats/000077500000000000000000000000001466406635600252165ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/report_formats/__init__.py000066400000000000000000000015231466406635600273300ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_clone_report_format import GmpCloneReportFormatTestMixin from .test_delete_report_format import GmpDeleteReportFormatTestMixin from .test_get_report_format import GmpGetReportFormatTestMixin from .test_get_report_formats import GmpGetReportFormatsTestMixin from .test_import_report_format import GmpImportReportFormatTestMixin from .test_modify_report_format import GmpModifyReportFormatTestMixin from .test_verify_report_format import GmpVerifyReportFormatTestMixin __all__ = ( "GmpCloneReportFormatTestMixin", "GmpDeleteReportFormatTestMixin", "GmpGetReportFormatTestMixin", "GmpGetReportFormatsTestMixin", "GmpImportReportFormatTestMixin", "GmpModifyReportFormatTestMixin", "GmpVerifyReportFormatTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/report_formats/test_clone_report_format.py000066400000000000000000000020141466406635600326670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import ReportFormatType class GmpCloneReportFormatTestMixin: def test_clone(self): self.gmp.clone_report_format("a1") self.connection.send.has_been_called_with( b"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}" "".encode("utf-8") ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/report_formats/test_delete_report_format.py000066400000000000000000000023551466406635600330410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError from gvm.protocols.gmp.requests.v224 import ReportFormatType class GmpDeleteReportFormatTestMixin: def test_delete(self): self.gmp.delete_report_format("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_report_format("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) 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( "'.encode( "utf-8" ) ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/report_formats/test_get_report_format.py000066400000000000000000000030521466406635600323510ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import ReportFormatType class GmpGetReportFormatTestMixin: def test_get_report_format(self): self.gmp.get_report_format("rf1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_report_format(report_format_id="rf1") self.connection.send.has_been_called_with( b'' ) 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( "'.encode( "utf-8" ) ) self.gmp.get_report_format(report_format_id=ReportFormatType.PDF) self.connection.send.has_been_called_with( "'.encode( "utf-8" ) ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/report_formats/test_get_report_formats.py000066400000000000000000000042701466406635600325370ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetReportFormatsTestMixin: def test_get_report_formats(self): self.gmp.get_report_formats() self.connection.send.has_been_called_with(b"") 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( b'' ) def test_get_report_formats_with_filter_id(self): self.gmp.get_report_formats(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_report_formats_with_trash(self): self.gmp.get_report_formats(trash=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_report_formats(trash=False) self.connection.send.has_been_called_with( b'' ) def test_get_report_formats_with_details(self): self.gmp.get_report_formats(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_report_formats(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_report_formats_with_alerts(self): self.gmp.get_report_formats(alerts=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_report_formats(alerts=False) self.connection.send.has_been_called_with( b'' ) def test_get_report_formats_with_params(self): self.gmp.get_report_formats(params=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_report_formats(params=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/report_formats/test_import_report_format.py000066400000000000000000000025301466406635600331040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument 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}".encode( "utf-8" ) ) 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-24.8.0/tests/protocols/gmpv224/entities/report_formats/test_modify_report_format.py000066400000000000000000000073201466406635600330630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 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( b'' ) 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( b'' b"foo" b"" ) 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( b'' b"foo" b"" ) 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".encode("utf-8") ) 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( b'' b"1" b"" ) self.gmp.modify_report_format(report_format_id="rf1", active=False) self.connection.send.has_been_called_with( b'' b"0" b"" ) 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( b'' b"" b"foo" b"" b"" ) 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( b'' b"" b"foo" b"bar" b"" b"" ) self.gmp.modify_report_format( report_format_id="rf1", param_name="foo", param_value="" ) self.connection.send.has_been_called_with( b'' b"" b"foo" b"" b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/report_formats/test_verify_report_format.py000066400000000000000000000017341466406635600331030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError from gvm.protocols.gmp.requests.v224 import ReportFormatType class GmpVerifyReportFormatTestMixin: def test_verify(self): self.gmp.verify_report_format("a1") self.connection.send.has_been_called_with( b'' ) 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''.encode( "utf-8" ) ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/reports/000077500000000000000000000000001466406635600236465ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/reports/__init__.py000066400000000000000000000007061466406635600257620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_delete_report import GmpDeleteReportTestMixin from .test_get_report import GmpGetReportTestMixin from .test_get_reports import GmpGetReportsTestMixin from .test_import_report import GmpImportReportTestMixin __all__ = ( "GmpDeleteReportTestMixin", "GmpGetReportTestMixin", "GmpGetReportsTestMixin", "GmpImportReportTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/reports/test_delete_report.py000066400000000000000000000010261466406635600301130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteReportTestMixin: def test_delete(self): self.gmp.delete_report("a1") self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_report(None) with self.assertRaises(GvmError): self.gmp.delete_report("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/reports/test_get_report.py000066400000000000000000000052731466406635600274400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 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( b'' ) 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( b'' ) 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( b'' ) 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( ''.encode("utf-8") ) 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( b'' ) 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( b'' ) self.gmp.get_report(report_id="r1", ignore_pagination=False) self.connection.send.has_been_called_with( b'' ) def test_get_report_with_details(self): self.gmp.get_report(report_id="r1", details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_report(report_id="r1", details=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/reports/test_get_reports.py000066400000000000000000000037071466406635600276230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetReportsTestMixin: def test_get_reports(self): self.gmp.get_reports() self.connection.send.has_been_called_with(b"") def test_get_reports_with_filter_string(self): self.gmp.get_reports(filter_string="name=foo", ignore_pagination=1) self.connection.send.has_been_called_with( b'' ) def test_get_reports_with_filter_id(self): self.gmp.get_reports(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_reports_without_note_details(self): self.gmp.get_reports(note_details=False) self.connection.send.has_been_called_with( b'' ) def test_get_reports_with_note_details(self): self.gmp.get_reports(note_details=True, ignore_pagination=False) self.connection.send.has_been_called_with( b'' ) def test_get_reports_without_override_details(self): self.gmp.get_reports(override_details=False) self.connection.send.has_been_called_with( b'' ) def test_get_reports_with_override_details(self): self.gmp.get_reports(override_details=True) self.connection.send.has_been_called_with( b'' ) def test_get_reports_with_details(self): self.gmp.get_reports(details=True) self.connection.send.has_been_called_with(b'') def test_get_reports_without_details(self): self.gmp.get_reports(details=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/reports/test_import_report.py000066400000000000000000000045001466406635600301630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument 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}" "".encode("utf-8") ) 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_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}" "".encode("utf-8") ) 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}" "".encode("utf-8") ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/results/000077500000000000000000000000001466406635600236515ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/results/__init__.py000066400000000000000000000004241466406635600257620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_result import GmpGetResultTestMixin from .test_get_results import GmpGetResultsTestMixin __all__ = ( "GmpGetResultTestMixin", "GmpGetResultsTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/results/test_get_result.py000066400000000000000000000013601466406635600274370ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetResultTestMixin: def test_get_result(self): self.gmp.get_result("r1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_result(result_id="r1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/results/test_get_results.py000066400000000000000000000036011466406635600276220ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetResultsTestMixin: def test_get_results(self): self.gmp.get_results() self.connection.send.has_been_called_with(b"") def test_get_results_with_filter_string(self): self.gmp.get_results(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_results_with_filter_id(self): self.gmp.get_results(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_results_with_note_details(self): self.gmp.get_results(note_details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_results(note_details=False) self.connection.send.has_been_called_with( b'' ) def test_get_results_with_override_details(self): self.gmp.get_results(override_details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_results(override_details=False) self.connection.send.has_been_called_with( b'' ) def test_get_results_with_details(self): self.gmp.get_results(details=True) self.connection.send.has_been_called_with(b'') self.gmp.get_results(details=False) self.connection.send.has_been_called_with(b'') def test_get_results_with_task_id(self): self.gmp.get_results(task_id="t1") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/roles/000077500000000000000000000000001466406635600232745ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/roles/__init__.py000066400000000000000000000011211466406635600254000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneRoleTestMixin", "GmpCreateRoleTestMixin", "GmpDeleteRoleTestMixin", "GmpGetRoleTestMixin", "GmpGetRolesTestMixin", "GmpModifyRoleTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/roles/test_clone_role.py000066400000000000000000000010541466406635600270260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneRoleTestMixin: def test_clone(self): self.gmp.clone_role("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/roles/test_create_role.py000066400000000000000000000024671466406635600272020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"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( b"" b"foo" b"bar" b"" ) def test_create_role_with_users(self): self.gmp.create_role(name="foo", users=[]) self.connection.send.has_been_called_with( b"foo" ) self.gmp.create_role(name="foo", users=["u1", "u2"]) self.connection.send.has_been_called_with( b"" b"foo" b"u1,u2" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/roles/test_delete_role.py000066400000000000000000000013441466406635600271720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteRoleTestMixin: def test_delete(self): self.gmp.delete_role("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_role("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_role(None) with self.assertRaises(GvmError): self.gmp.delete_role("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/roles/test_get_role.py000066400000000000000000000012201466406635600265000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetRoleTestMixin: def test_get_role(self): self.gmp.get_role("r1") self.connection.send.has_been_called_with(b'') self.gmp.get_role(role_id="r1") self.connection.send.has_been_called_with(b'') 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-24.8.0/tests/protocols/gmpv224/entities/roles/test_get_roles.py000066400000000000000000000016171466406635600266750ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetRolesTestMixin: def test_get_roles(self): self.gmp.get_roles() self.connection.send.has_been_called_with(b"") def test_get_roles_with_filter_string(self): self.gmp.get_roles(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_roles_with_filter_id(self): self.gmp.get_roles(filter_id="f1") self.connection.send.has_been_called_with(b'') def test_get_roles_with_trash(self): self.gmp.get_roles(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_roles(trash=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/roles/test_modify_role.py000066400000000000000000000034371466406635600272240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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( b'' b"foo" b"" ) def test_modify_role_with_name(self): self.gmp.modify_role(role_id="r1", name="foo") self.connection.send.has_been_called_with( b'foo' ) def test_modify_role_with_users(self): self.gmp.modify_role(role_id="r1", users=[]) self.connection.send.has_been_called_with( b'' ) self.gmp.modify_role(role_id="r1", users=["foo"]) self.connection.send.has_been_called_with( b'foo' ) self.gmp.modify_role(role_id="r1", users=["foo", "bar"]) self.connection.send.has_been_called_with( b'' b"foo,bar" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs/000077500000000000000000000000001466406635600246045ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs/__init__.py000066400000000000000000000035631466406635600267240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_clone_scan_config import GmpCloneScanConfigTestMixin from .test_create_scan_config import GmpCreateScanConfigTestMixin from .test_delete_scan_config import GmpDeleteScanConfigTestMixin from .test_get_scan_config import GmpGetScanConfigTestMixin from .test_get_scan_config_preference import GmpGetScanConfigPreferenceTestMixin from .test_get_scan_config_preferences import ( GmpGetScanConfigPreferencesTestMixin, ) from .test_get_scan_configs import GmpGetScanConfigsTestMixin from .test_import_scan_config import GmpImportScanConfigTestMixin 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, ) __all__ = ( "GmpCloneScanConfigTestMixin", "GmpCreateScanConfigTestMixin", "GmpDeleteScanConfigTestMixin", "GmpGetScanConfigTestMixin", "GmpGetScanConfigPreferenceTestMixin", "GmpGetScanConfigPreferencesTestMixin", "GmpGetScanConfigsTestMixin", "GmpImportScanConfigTestMixin", "GmpModifyScanConfigSetCommentTestMixin", "GmpModifyScanConfigSetFamilySelectionTestMixin", "GmpModifyScanConfigSetNameTestMixin", "GmpModifyScanConfigSetNvtPreferenceTestMixin", "GmpModifyScanConfigSetNvtSelectionTestMixin", "GmpModifyScanConfigSetScannerPreferenceTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_clone_scan_config.py000066400000000000000000000011131466406635600316420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneScanConfigTestMixin: def test_clone(self): self.gmp.clone_scan_config("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_create_scan_config.py000066400000000000000000000027051466406635600320150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"" b"a1" b"foo" b"scan" b"" ) def test_create_scan_config_with_comment(self): self.gmp.create_scan_config("a1", "foo", comment="comment") self.connection.send.has_been_called_with( b"" b"comment" b"a1" b"foo" b"scan" b"" ) 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="") python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_delete_scan_config.py000066400000000000000000000015051466406635600320110ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) def test_delete_scan_config_ultimate(self): self.gmp.delete_scan_config("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_get_scan_config.py000066400000000000000000000015511466406635600313270ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) def test_get_scan_config_with_tasks(self): self.gmp.get_scan_config("a1", tasks=True) self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_get_scan_config_preference.py000066400000000000000000000024121466406635600335220ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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( b'' ) 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( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_get_scan_config_preferences.py000066400000000000000000000014141466406635600337060ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetScanConfigPreferencesTestMixin: def test_get_scan_config_preferences(self): self.gmp.get_scan_config_preferences() self.connection.send.has_been_called_with(b"") 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( b'' ) 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( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_get_scan_configs.py000066400000000000000000000053731466406635600315200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetScanConfigsTestMixin: def test_get_scan_configs_simple(self): self.gmp.get_scan_configs() self.connection.send.has_been_called_with( b'' ) 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( b'' ) def test_get_scan_configs_with_filter_id(self): self.gmp.get_scan_configs(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_from_trash(self): self.gmp.get_scan_configs(trash=True) self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_with_details(self): self.gmp.get_scan_configs(details=True) self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_without_details(self): self.gmp.get_scan_configs(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_with_families(self): self.gmp.get_scan_configs(families=True) self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_without_families(self): self.gmp.get_scan_configs(families=False) self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_with_preferences(self): self.gmp.get_scan_configs(preferences=True) self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_without_preferences(self): self.gmp.get_scan_configs(preferences=False) self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_with_tasks(self): self.gmp.get_scan_configs(tasks=True) self.connection.send.has_been_called_with( b'' ) def test_get_scan_configs_without_tasks(self): self.gmp.get_scan_configs(tasks=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_import_scan_config.py000066400000000000000000000023651466406635600320660ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument 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}".encode( "utf-8" ) ) 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-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_modify_scan_config.py000066400000000000000000000110141466406635600320320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import warnings from gvm.errors import InvalidArgument, RequiredArgument 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( b'' b"foo" b"" ) 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( b'' b"" b'' b"foo" b"" b"" ) 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( b'' b"" b"foo" b"YmFy" b"" b"" ) 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( b'' b"" b"foo" b'' b"" b"" ) 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"" ) test_modify_scan_config_set_comment.py000066400000000000000000000025321466406635600343550ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"" b"" ) self.gmp.modify_scan_config_set_comment("c1", comment="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) self.gmp.modify_scan_config_set_comment("c1", comment=None) self.connection.send.has_been_called_with( b'' b"" b"" ) 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.py000066400000000000000000000173231466406635600362450ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"" ) 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"bar" b"1" b"1" b"" b"" b"" ) 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"bar" b"1" b"1" b"" b"" b"" ) 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( b'' b"" b"1" b"" b"foo" b"0" b"1" b"" b"" b"bar" b"1" b"0" b"" b"" b"" ) 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"" ) 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( b'' b"" b"0" b"" b"foo" b"1" b"1" b"" b"" b"" ) 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( b'' b"" b"1" b"" b"foo" b"1" b"1" b"" b"" b"" ) self.gmp.modify_scan_config_set_family_selection( config_id="c1", families=[("foo", False, True)] ) self.connection.send.has_been_called_with( b'' b"" b"1" b"" b"foo" b"1" b"0" b"" b"" b"" ) 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( b'' b"" b"1" b"" b"foo" b"1" b"0" b"" b"" b"bar" b"0" b"1" b"" b"" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/scan_configs/test_modify_scan_config_set_name.py000066400000000000000000000024501466406635600337110ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"foo" b"" ) 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.py000066400000000000000000000061701466406635600357220ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"" b'' b"foo" b"" b"" ) self.gmp.modify_scan_config_set_nvt_preference("c1", "foo", "o1") self.connection.send.has_been_called_with( b'' b"" b'' b"foo" b"" b"" ) 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( b'' b"" b'' b"foo" b"YmFy" b"" b"" ) 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.py000066400000000000000000000074701466406635600355750ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgumentType, RequiredArgument 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( b'' b"" b"foo" b'' b"" b"" ) self.gmp.modify_scan_config_set_nvt_selection( config_id="c1", family="foo", nvt_oids=["o1", "o2"] ) self.connection.send.has_been_called_with( b'' b"" b"foo" b'' b'' b"" b"" ) self.gmp.modify_scan_config_set_nvt_selection("c1", "foo", ["o1"]) self.connection.send.has_been_called_with( b'' b"" b"foo" b'' b"" b"" ) self.gmp.modify_scan_config_set_nvt_selection("c1", "foo", ("o1", "o2")) self.connection.send.has_been_called_with( b'' b"" b"foo" b'' b'' b"" b"" ) self.gmp.modify_scan_config_set_nvt_selection( config_id="c1", family="foo", nvt_oids=[] ) self.connection.send.has_been_called_with( b'' b"" b"foo" b"" b"" ) 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.py000066400000000000000000000046151466406635600365460ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/scan_configs# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"" b"foo" b"" b"" ) self.gmp.modify_scan_config_set_scanner_preference("c1", "foo") self.connection.send.has_been_called_with( b'' b"" b"foo" b"" b"" ) 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( b'' b"" b"foo" b"YmFy" b"" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/scanners/000077500000000000000000000000001466406635600237645ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/scanners/__init__.py000066400000000000000000000013431466406635600260760ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneScannerTestMixin", "GmpCreateScannerTestMixin", "GmpDeleteScannerTestMixin", "GmpGetScannerTestMixin", "GmpGetScannersTestMixin", "GmpModifyScannerTestMixin", "GmpVerifyScannerTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scanners/test_clone_scanner.py000066400000000000000000000010761466406635600302120ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneScannerTestMixin: def test_clone(self): self.gmp.clone_scanner("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/scanners/test_create_scanner.py000066400000000000000000000135021466406635600303520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import ScannerType class GmpCreateScannerTestMixin: def test_create_scanner(self): self.gmp.create_scanner( name="foo", host="localhost", port=1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", ) self.connection.send.has_been_called_with( b"" b"foo" b"localhost" b"1234" b"2" b'' b"" ) def test_create_scanner_missing_name(self): with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name=None, host="localhost", port=1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name="", host="localhost", port=1234, scanner_type="2", 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.OPENVAS_SCANNER_TYPE, credential_id="c1", ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name="foo", host="", port=1234, scanner_type=ScannerType.OPENVAS_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.OPENVAS_SCANNER_TYPE, credential_id="c1", ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name="foo", host="localhost", port="", scanner_type=ScannerType.OPENVAS_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.OPENVAS_SCANNER_TYPE, credential_id=None, ) with self.assertRaises(RequiredArgument): self.gmp.create_scanner( name="foo", host="localhost", port=1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="", ) def test_create_scanner_invalid_scanner_type(self): with self.assertRaises(InvalidArgument): 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.FOO, # pylint: disable=no-member credential_id="c1", ) with self.assertRaises(InvalidArgument): 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.OPENVAS_SCANNER_TYPE, credential_id="c1", ) self.connection.send.has_been_called_with( b"" b"foo" b"localhost" b"1234" b"2" b'' b"foo" b"" ) def test_create_scanner_with_comment(self): self.gmp.create_scanner( name="foo", host="localhost", port=1234, scanner_type=ScannerType.OPENVAS_SCANNER_TYPE, credential_id="c1", comment="bar", ) self.connection.send.has_been_called_with( b"" b"foo" b"localhost" b"1234" b"2" b'' b"bar" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scanners/test_delete_scanner.py000066400000000000000000000013771466406635600303600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteScannerTestMixin: def test_delete(self): self.gmp.delete_scanner("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_scanner("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_scanner(None) with self.assertRaises(GvmError): self.gmp.delete_scanner("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/scanners/test_get_scanner.py000066400000000000000000000013761466406635600276740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetScannerTestMixin: def test_get_scanner(self): self.gmp.get_scanner("s1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_scanner(scanner_id="s1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/scanners/test_get_scanners.py000066400000000000000000000024551466406635600300560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetScannersTestMixin: def test_get_scanners(self): self.gmp.get_scanners() self.connection.send.has_been_called_with(b"") def test_get_scanners_with_filter_string(self): self.gmp.get_scanners(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_scanners_with_filter_id(self): self.gmp.get_scanners(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_scanners_with_trash(self): self.gmp.get_scanners(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_scanners(trash=False) self.connection.send.has_been_called_with(b'') def test_get_scanners_with_details(self): self.gmp.get_scanners(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_scanners(details=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scanners/test_modify_scanner.py000066400000000000000000000077011466406635600304020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import ScannerType class GmpModifyScannerTestMixin: def test_modify_scanner(self): self.gmp.modify_scanner(scanner_id="s1") self.connection.send.has_been_called_with( b'' ) 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( b'' b"foo" b"" ) def test_modify_scanner_with_host(self): self.gmp.modify_scanner(scanner_id="s1", host="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) def test_modify_scanner_with_port(self): self.gmp.modify_scanner(scanner_id="s1", port=1234) self.connection.send.has_been_called_with( b'' b"1234" b"" ) self.gmp.modify_scanner(scanner_id="s1", port="1234") self.connection.send.has_been_called_with( b'' b"1234" b"" ) def test_modify_scanner_with_name(self): self.gmp.modify_scanner(scanner_id="s1", name="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) 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( b'' b"foo" b"" ) 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( b'' b'' b"" ) def test_modify_scanner_with_scanner_type(self): self.gmp.modify_scanner( scanner_id="s1", scanner_type=ScannerType.OPENVAS_SCANNER_TYPE ) self.connection.send.has_been_called_with( b'' b"2" b"" ) self.gmp.modify_scanner( scanner_id="s1", scanner_type=ScannerType.CVE_SCANNER_TYPE ) self.connection.send.has_been_called_with( b'' b"3" b"" ) self.gmp.modify_scanner( scanner_id="s1", scanner_type=ScannerType.GREENBONE_SENSOR_SCANNER_TYPE, ) self.connection.send.has_been_called_with( b'' b"5" b"" ) def test_modify_scanner_invalid_scanner_type(self): with self.assertRaises(ValueError): self.gmp.modify_scanner(scanner_id="s1", scanner_type="") with self.assertRaises(InvalidArgument): self.gmp.modify_scanner(scanner_id="s1", scanner_type="-1") with self.assertRaises(InvalidArgument): self.gmp.modify_scanner(scanner_id="s1", scanner_type=1) python-gvm-24.8.0/tests/protocols/gmpv224/entities/scanners/test_verify_scanner.py000066400000000000000000000010341466406635600304100ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpVerifyScannerTestMixin: def test_verify(self): self.gmp.verify_scanner("a1") self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.verify_scanner(None) with self.assertRaises(GvmError): self.gmp.verify_scanner("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/schedules/000077500000000000000000000000001466406635600241275ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/schedules/__init__.py000066400000000000000000000012311466406635600262350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneScheduleTestMixin", "GmpCreateScheduleTestMixin", "GmpDeleteScheduleTestMixin", "GmpGetScheduleTestMixin", "GmpGetSchedulesTestMixin", "GmpModifyScheduleTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/schedules/test_clone_schedule.py000066400000000000000000000011041466406635600305100ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneScheduleTestMixin: def test_clone(self): self.gmp.clone_schedule("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/schedules/test_create_schedule.py000066400000000000000000000052031466406635600306570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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" "".encode("utf-8") ) 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" "".encode("utf-8") ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/schedules/test_delete_schedule.py000066400000000000000000000014101466406635600306520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteScheduleTestMixin: def test_delete(self): self.gmp.delete_schedule("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_schedule("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_schedule(None) with self.assertRaises(GvmError): self.gmp.delete_schedule("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/schedules/test_get_schedule.py000066400000000000000000000022161466406635600301740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetScheduleTestMixin: def test_get_schedule(self): self.gmp.get_schedule("s1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_schedule(schedule_id="s1") self.connection.send.has_been_called_with( b'' ) 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( b'' ) self.gmp.get_schedule(schedule_id="s1", tasks=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/schedules/test_get_schedules.py000066400000000000000000000024131466406635600303560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetSchedulesTestMixin: def test_get_schedules(self): self.gmp.get_schedules() self.connection.send.has_been_called_with(b"") def test_get_schedules_with_filter_string(self): self.gmp.get_schedules(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_schedules_with_filter_id(self): self.gmp.get_schedules(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_schedules_with_trash(self): self.gmp.get_schedules(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_schedules(trash=False) self.connection.send.has_been_called_with(b'') def test_get_schedules_with_tasks(self): self.gmp.get_schedules(tasks=True) self.connection.send.has_been_called_with(b'') self.gmp.get_schedules(tasks=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/schedules/test_modify_schedule.py000066400000000000000000000040321466406635600307020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"foo" b"" ) def test_modify_schedule_with_comment(self): self.gmp.modify_schedule(schedule_id="s1", comment="bar") self.connection.send.has_been_called_with( b'' b"bar" b"" ) 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}" "".encode("utf-8") ) def test_modify_schedule_with_timezone(self): self.gmp.modify_schedule(schedule_id="s1", timezone="Europe/Berlin") self.connection.send.has_been_called_with( b'' b"Europe/Berlin" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/000077500000000000000000000000001466406635600235765ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/__init__.py000066400000000000000000000034441466406635600257140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_cert_bund_advisories import GmpGetCertBundListTestMixin from .test_get_cert_bund_advisory import GmpGetCertBundTestMixin 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_advisories import GmpGetDfnCertListTestMixin from .test_get_dfn_cert_advisory import GmpGetDfnCertTestMixin 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_nvt_preference import GmpGetNvtPreferenceTestMixin from .test_get_nvt_preferences import GmpGetNvtPreferencesTestMixin from .test_get_nvts import GmpGetNvtListTestMixin 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 __all__ = ( "GmpGetCertBundListTestMixin", "GmpGetCertBundTestMixin", "GmpGetCpeTestMixin", "GmpGetCpeListTestMixin", "GmpGetCveTestMixin", "GmpGetCveListTestMixin", "GmpGetDfnCertListTestMixin", "GmpGetDfnCertTestMixin", "GmpGetInfoTestMixin", "GmpGetInfoListTestMixin", "GmpGetNvtTestMixin", "GmpGetNvtFamiliesTestMixin", "GmpGetNvtPreferenceTestMixin", "GmpGetNvtPreferencesTestMixin", "GmpGetNvtListTestMixin", "GmpGetOvalDefTestMixin", "GmpGetOvalDefListTestMixin", "GmpGetScanConfigNvtTestMixin", "GmpGetScanConfigNvtsTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_cert_bund_advisories.py000066400000000000000000000025721466406635600322510ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetCertBundListTestMixin: def test_get_cpes(self): self.gmp.get_cert_bund_advisories() self.connection.send.has_been_called_with( b'' ) 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( b'' ) def test_get_cves_with_filter_id(self): self.gmp.get_cert_bund_advisories(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_cves_with_name(self): self.gmp.get_cert_bund_advisories(name="foo") self.connection.send.has_been_called_with( b'' ) def test_get_cves_with_details(self): self.gmp.get_cert_bund_advisories(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_cert_bund_advisories(details=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_cert_bund_advisory.py000066400000000000000000000016771466406635600317460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) self.gmp.get_cert_bund_advisory("i1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_cpe.py000066400000000000000000000014711466406635600266200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) self.gmp.get_cpe("i1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_cpes.py000066400000000000000000000023031466406635600267760ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetCpeListTestMixin: def test_get_cpes(self): self.gmp.get_cpes() self.connection.send.has_been_called_with(b'') def test_get_cpes_with_filter_string(self): self.gmp.get_cpes(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_cpes_with_filter_id(self): self.gmp.get_cpes(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_cpes_with_name(self): self.gmp.get_cpes(name="foo") self.connection.send.has_been_called_with( b'' ) def test_get_cpes_with_details(self): self.gmp.get_cpes(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_cpes(details=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_cve.py000066400000000000000000000014711466406635600266260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) self.gmp.get_cve("i1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_cves.py000066400000000000000000000023031466406635600270040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetCveListTestMixin: def test_get_cpes(self): self.gmp.get_cves() self.connection.send.has_been_called_with(b'') def test_get_cves_with_filter_string(self): self.gmp.get_cves(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_cves_with_filter_id(self): self.gmp.get_cves(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_cves_with_name(self): self.gmp.get_cves(name="foo") self.connection.send.has_been_called_with( b'' ) def test_get_cves_with_details(self): self.gmp.get_cves(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_cves(details=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_dfn_cert_advisories.py000066400000000000000000000025551466406635600320710ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetDfnCertListTestMixin: def test_get_cpes(self): self.gmp.get_dfn_cert_advisories() self.connection.send.has_been_called_with( b'' ) 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( b'' ) def test_get_cves_with_filter_id(self): self.gmp.get_dfn_cert_advisories(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_cves_with_name(self): self.gmp.get_dfn_cert_advisories(name="foo") self.connection.send.has_been_called_with( b'' ) def test_get_cves_with_details(self): self.gmp.get_dfn_cert_advisories(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_dfn_cert_advisories(details=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_dfn_cert_advisory.py000066400000000000000000000016671466406635600315640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) self.gmp.get_dfn_cert_advisory("i1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_info.py000066400000000000000000000045751466406635600270140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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( b'' ) self.gmp.get_info("i1", InfoType.CPE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_info("i1", InfoType.CVE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_info("i1", InfoType.DFN_CERT_ADV) self.connection.send.has_been_called_with( b'' ) self.gmp.get_info("i1", InfoType.OVALDEF) self.connection.send.has_been_called_with( b'' ) self.gmp.get_info("i1", InfoType.NVT) self.connection.send.has_been_called_with( b'' ) 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(InvalidArgument): 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-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_info_list.py000066400000000000000000000057031466406635600300410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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( b'' ) self.gmp.get_info_list(InfoType.CPE) self.connection.send.has_been_called_with(b'') self.gmp.get_info_list(info_type=InfoType.CPE) self.connection.send.has_been_called_with(b'') self.gmp.get_info_list(InfoType.CVE) self.connection.send.has_been_called_with(b'') self.gmp.get_info_list(InfoType.DFN_CERT_ADV) self.connection.send.has_been_called_with( b'' ) self.gmp.get_info_list(InfoType.OVALDEF) self.connection.send.has_been_called_with(b'') self.gmp.get_info_list(InfoType.NVT) self.connection.send.has_been_called_with(b'') 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(InvalidArgument): 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( b'' ) 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( b'' ) 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( b'' ) 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( b'' ) self.gmp.get_info_list(info_type=InfoType.CPE, details=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_nvt.py000066400000000000000000000027001466406635600266540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) self.gmp.get_nvt("i1") self.connection.send.has_been_called_with( b'' ) 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) def test_get_extended_nvt_with_nvt_oid(self): self.gmp.get_nvt(extended=True, nvt_id="nvt_oid") self.connection.send.has_been_called_with( b'' ) def test_get_extended_nvt_missing_nvt_oid(self): with self.assertRaises(RequiredArgument): self.gmp.get_nvt(extended=True, nvt_id=None) with self.assertRaises(RequiredArgument): self.gmp.get_nvt(extended=True, nvt_id="") with self.assertRaises(RequiredArgument): self.gmp.get_nvt("", extended=True) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_nvt_families.py000066400000000000000000000007651466406635600305360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetNvtFamiliesTestMixin: def test_get_nvt_families(self): self.gmp.get_nvt_families() self.connection.send.has_been_called_with(b"") def test_get_nvt_families_with_sort_order(self): self.gmp.get_nvt_families(sort_order="foo") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_nvt_preference.py000066400000000000000000000017041466406635600310550ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_nvt_preferences.py000066400000000000000000000007711466406635600312430ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetNvtPreferencesTestMixin: def test_get_nvt_preferences(self): self.gmp.get_nvt_preferences() self.connection.send.has_been_called_with(b"") def test_get_nvt_preferences_with_nvt_oid(self): self.gmp.get_nvt_preferences(nvt_oid="oid") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_nvts.py000066400000000000000000000074151466406635600270470ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetNvtListTestMixin: def test_get_nvts(self): self.gmp.get_nvts() self.connection.send.has_been_called_with(b'') def test_get_nvts_with_filter_string(self): self.gmp.get_nvts(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_nvts_with_filter_id(self): self.gmp.get_nvts(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_nvts_with_name(self): self.gmp.get_nvts(name="foo") self.connection.send.has_been_called_with( b'' ) def test_get_nvts_with_details(self): self.gmp.get_nvts(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_nvts(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_extended_nvts(self): self.gmp.get_nvts(extended=True) self.connection.send.has_been_called_with(b"") def test_get_extended_nvts_with_details(self): self.gmp.get_nvts(extended=True, details=True) self.connection.send.has_been_called_with(b'') self.gmp.get_nvts(extended=True, details=False) self.connection.send.has_been_called_with(b'') def test_get_extended_nvts_with_preferences(self): self.gmp.get_nvts(extended=True, preferences=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_nvts(extended=True, preferences=False) self.connection.send.has_been_called_with( b'' ) def test_get_extended_nvts_with_preference_count(self): self.gmp.get_nvts(extended=True, preference_count=True) self.connection.send.has_been_called_with( b'' ) def test_get_extended_nvts_with_timeout(self): self.gmp.get_nvts(extended=True, timeout=True) self.connection.send.has_been_called_with(b'') self.gmp.get_nvts(extended=True, timeout=False) self.connection.send.has_been_called_with(b'') def test_get_extended_nvts_with_config_id(self): self.gmp.get_nvts(extended=True, config_id="config_id") self.connection.send.has_been_called_with( b'' ) def test_get_extended_nvts_with_preferences_config_id(self): self.gmp.get_nvts( extended=True, preferences_config_id="preferences_config_id" ) self.connection.send.has_been_called_with( b'' ) def test_get_extended_nvts_with_family(self): self.gmp.get_nvts(extended=True, family="family") self.connection.send.has_been_called_with( b'' ) def test_get_extended_nvts_with_sort_order(self): self.gmp.get_nvts(extended=True, sort_order="sort_order") self.connection.send.has_been_called_with( b'' ) def test_get_extended_nvts_with_sort_field(self): self.gmp.get_nvts(extended=True, sort_field="sort_field") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_oval_definition.py000066400000000000000000000016351466406635600312240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) self.gmp.get_oval_definition("i1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_oval_definitions.py000066400000000000000000000025431466406635600314060ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetOvalDefListTestMixin: def test_get_oval_definitions(self): self.gmp.get_oval_definitions() self.connection.send.has_been_called_with(b'') 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( b'' ) def test_get_oval_definitions_with_filter_id(self): self.gmp.get_oval_definitions(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_oval_definitions_with_name(self): self.gmp.get_oval_definitions(name="foo") self.connection.send.has_been_called_with( b'' ) def test_get_oval_definitions_with_details(self): self.gmp.get_oval_definitions(details=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_oval_definitions(details=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_scan_config_nvt.py000066400000000000000000000014631466406635600312120ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/secinfo/test_get_scan_config_nvts.py000066400000000000000000000053211466406635600313720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetScanConfigNvtsTestMixin: def test_get_scan_config_nvts_simple(self): self.gmp.get_scan_config_nvts() self.connection.send.has_been_called_with(b"") def test_get_scan_config_nvts_with_details(self): self.gmp.get_scan_config_nvts(details=True) self.connection.send.has_been_called_with(b'') self.gmp.get_scan_config_nvts(details=False) self.connection.send.has_been_called_with(b'') def test_get_scan_config_nvts_with_preferences(self): self.gmp.get_scan_config_nvts(preferences=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_scan_config_nvts(preferences=False) self.connection.send.has_been_called_with( b'' ) 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( b'' ) def test_get_scan_config_nvts_with_timeout(self): self.gmp.get_scan_config_nvts(timeout=True) self.connection.send.has_been_called_with(b'') self.gmp.get_scan_config_nvts(timeout=False) self.connection.send.has_been_called_with(b'') 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( b'' ) 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( b'' ) def test_get_scan_config_nvts_with_family(self): self.gmp.get_scan_config_nvts(family="family") self.connection.send.has_been_called_with( b'' ) 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( b'' ) 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( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tags/000077500000000000000000000000001466406635600231065ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/tags/__init__.py000066400000000000000000000010771466406635600252240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneTagTestMixin", "GmpCreateTagTestMixin", "GmpDeleteTagTestMixin", "GmpGetTagTestMixin", "GmpGetTagsTestMixin", "GmpModifyTagTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tags/test_clone_tag.py000066400000000000000000000010461466406635600264530ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneTagTestMixin: def test_clone(self): self.gmp.clone_tag("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/tags/test_create_tag.py000066400000000000000000000164351466406635600266260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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( b"" b"foo" b"" b"task" b"" b"" ) self.gmp.create_tag( name="foo", resource_filter=None, resource_ids=[], resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( b"" b"foo" b"" b"task" b"" b"" ) self.gmp.create_tag(name="foo", resource_type=EntityType.TASK) self.connection.send.has_been_called_with( b"" b"foo" b"" b"task" b"" b"" ) 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(InvalidArgument): 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( b"" b"foo" b'' b"task" b"" b"" ) 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( b"" b"foo" b'' b"task" b"" b"" ) 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( b"" b"foo" b'' b"config" b"" b"" ) 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( b"" b"foo" b"" b'' b"task" b"" b"" ) self.gmp.create_tag( name="foo", resource_ids=["foo", "bar"], resource_type=EntityType.TASK, ) self.connection.send.has_been_called_with( b"" b"foo" b"" b'' b'' b"task" b"" b"" ) 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( b"" b"foo" b"" b'' b"task" b"" b"bar" b"" ) 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( b"" b"foo" b"" b'' b"task" b"" b"bar" b"" ) 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( b"" b"foo" b"" b'' b"task" b"" b"1" b"" ) self.gmp.create_tag( name="foo", resource_ids=["foo"], resource_type=EntityType.TASK, active=False, ) self.connection.send.has_been_called_with( b"" b"foo" b"" b'' b"task" b"" b"0" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tags/test_delete_tag.py000066400000000000000000000013331466406635600266140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteTagTestMixin: def test_delete(self): self.gmp.delete_tag("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_tag("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_tag(None) with self.assertRaises(GvmError): self.gmp.delete_tag("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/tags/test_get_tag.py000066400000000000000000000012021466406635600261240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetTagTestMixin: def test_get_tag(self): self.gmp.get_tag("t1") self.connection.send.has_been_called_with(b'') self.gmp.get_tag(tag_id="t1") self.connection.send.has_been_called_with(b'') 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-24.8.0/tests/protocols/gmpv224/entities/tags/test_get_tags.py000066400000000000000000000022521466406635600263150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetTagsTestMixin: def test_get_tags(self): self.gmp.get_tags() self.connection.send.has_been_called_with(b"") def test_get_tags_with_filter_string(self): self.gmp.get_tags(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_tags_with_filter_id(self): self.gmp.get_tags(filter_id="f1") self.connection.send.has_been_called_with(b'') def test_get_tags_with_trash(self): self.gmp.get_tags(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_tags(trash=False) self.connection.send.has_been_called_with(b'') def test_get_tags_with_names_only(self): self.gmp.get_tags(names_only=True) self.connection.send.has_been_called_with(b'') self.gmp.get_tags(names_only=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/tags/test_modify_tag.py000066400000000000000000000134231466406635600266440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import EntityType class GmpModifyTagTestMixin: def test_modify_tag(self): self.gmp.modify_tag(tag_id="t1") self.connection.send.has_been_called_with(b'') 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( b'foo' ) def test_modify_tag_with_value(self): self.gmp.modify_tag(tag_id="t1", value="foo") self.connection.send.has_been_called_with( b'foo' ) def test_modify_tag_with_name(self): self.gmp.modify_tag(tag_id="t1", name="foo") self.connection.send.has_been_called_with( b'foo' ) def test_modify_tag_with_active(self): self.gmp.modify_tag(tag_id="t1", active=True) self.connection.send.has_been_called_with( b'1' ) self.gmp.modify_tag(tag_id="t1", active=False) self.connection.send.has_been_called_with( b'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( b'' b'' b"task" b"" b"" ) 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( b'' b'' b"task" b"" b"" ) 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( b'' b'' b"config" b"" b"" ) 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( b'' b'' b"task" b"" b"" ) 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( b'' b"" b'' b"task" b"" b"" ) 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( b'' b'' b'' b"task" b"" b"" ) 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( b'' b'' b"" ) 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( b'' b"" b'' b"" b"" ) 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(InvalidArgument): 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( b'' b"" b"task" b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/targets/000077500000000000000000000000001466406635600236215ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/targets/__init__.py000066400000000000000000000011651466406635600257350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneTargetTestMixin", "GmpCreateTargetTestMixin", "GmpDeleteTargetTestMixin", "GmpGetTargetTestMixin", "GmpGetTargetsTestMixin", "GmpModifyTargetTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/targets/test_clone_target.py000066400000000000000000000012661466406635600277050ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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}" "".encode("utf-8") ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.clone_target("") with self.assertRaises(RequiredArgument): self.gmp.clone_target(None) python-gvm-24.8.0/tests/protocols/gmpv224/entities/targets/test_create_target.py000066400000000000000000000163161466406635600300520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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( b"" b"foo" b'' b"" ) 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( b"" b"foo" b"foo" b"bar" b"" ) 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( b"" b"foo" b"foo,bar" b"bar,ipsum" b"" ) 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( b"" b"foo" b"foo" b'' b"" ) 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( b"" b"foo" b"foo" b'' b"123" b"" b"" ) 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( b"" b"foo" b"foo" b'' b"" ) 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( b"" b"foo" b"foo" b'' b"" ) 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( b"" b"foo" b"foo" b'' b"" ) 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( b"" b"foo" b"foo" b"ICMP Ping" b"" ) def test_create_target_invalid_alive_tests(self): with self.assertRaises(InvalidArgument): 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( b"" b"foo" b"foo" b"1" b"" ) self.gmp.create_target( "foo", hosts=["foo"], allow_simultaneous_ips=False ) self.connection.send.has_been_called_with( b"" b"foo" b"foo" b"0" b"" ) 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( b"" b"foo" b"foo" b"1" b"" ) self.gmp.create_target("foo", hosts=["foo"], reverse_lookup_only=False) self.connection.send.has_been_called_with( b"" b"foo" b"foo" b"0" b"" ) 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( b"" b"foo" b"foo" b"1" b"" ) self.gmp.create_target("foo", hosts=["foo"], reverse_lookup_unify=False) self.connection.send.has_been_called_with( b"" b"foo" b"foo" b"0" b"" ) 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( b"" b"foo" b"foo" b"bar" b"" ) 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( b"" b"foo" b"foo" b'' b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/targets/test_delete_target.py000066400000000000000000000013661466406635600300500ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteTargetTestMixin: def test_delete(self): self.gmp.delete_target("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_target("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_target(None) with self.assertRaises(GvmError): self.gmp.delete_target("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/targets/test_get_target.py000066400000000000000000000021371466406635600273620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetTargetTestMixin: def test_get_target(self): self.gmp.get_target("t1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_target(target_id="t1") self.connection.send.has_been_called_with( b'' ) 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( b'' ) self.gmp.get_target(target_id="t1", tasks=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/targets/test_get_targets.py000066400000000000000000000023431466406635600275440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetTargetsTestMixin: def test_get_targets(self): self.gmp.get_targets() self.connection.send.has_been_called_with(b"") def test_get_targets_with_filter_string(self): self.gmp.get_targets(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_targets_with_filter_id(self): self.gmp.get_targets(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_targets_with_trash(self): self.gmp.get_targets(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_targets(trash=False) self.connection.send.has_been_called_with(b'') def test_get_targets_with_tasks(self): self.gmp.get_targets(tasks=True) self.connection.send.has_been_called_with(b'') self.gmp.get_targets(tasks=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/targets/test_modify_target.py000066400000000000000000000160121466406635600300670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import AliveTest class GmpModifyTargetTestMixin: def test_modify_target(self): self.gmp.modify_target(target_id="t1") self.connection.send.has_been_called_with( b'' ) 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( b'' b"foo" b"" ) def test_modify_target_with_hosts(self): self.gmp.modify_target(target_id="t1", hosts=["foo"]) self.connection.send.has_been_called_with( b'' b"foo" b"" b"" ) self.gmp.modify_target(target_id="t1", hosts=["foo", "bar"]) self.connection.send.has_been_called_with( b'' b"foo,bar" b"" b"" ) 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( b'' b"foo,bar" b"foo" b"" ) def test_modify_target_with_name(self): self.gmp.modify_target(target_id="t1", name="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) 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( b'' b"foo" b"" ) self.gmp.modify_target(target_id="t1", exclude_hosts=["foo", "bar"]) self.connection.send.has_been_called_with( b'' b"foo,bar" b"" ) 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( b'' b'' b"" ) 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( b'' b'' b"123" b"" b"" ) 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( b'' b'' b"" ) 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( b'' b'' b"" ) 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( b'' b'' b"" ) 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( b'' b"ICMP Ping" b"" ) def test_modify_target_invalid_alive_tests(self): with self.assertRaises(InvalidArgument): 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( b'' b"1" b"" ) self.gmp.modify_target(target_id="t1", allow_simultaneous_ips=False) self.connection.send.has_been_called_with( b'' b"0" b"" ) 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( b'' b"1" b"" ) self.gmp.modify_target(target_id="t1", reverse_lookup_only=False) self.connection.send.has_been_called_with( b'' b"0" b"" ) 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( b'' b"1" b"" ) self.gmp.modify_target(target_id="t1", reverse_lookup_unify=False) self.connection.send.has_been_called_with( b'' b"0" b"" ) 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( b'' b'' b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/000077500000000000000000000000001466406635600232755ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/__init__.py000066400000000000000000000017751466406635600254200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneTaskTestMixin", "GmpCreateContainerTaskTestMixin", "GmpCreateTaskTestMixin", "GmpDeleteTaskTestMixin", "GmpGetTaskTestMixin", "GmpGetTasksTestMixin", "GmpModifyTaskTestMixin", "GmpMoveTaskTestMixin", "GmpResumeTaskTestMixin", "GmpStartTaskTestMixin", "GmpStopTaskTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/test_clone_task.py000066400000000000000000000010541466406635600270300ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneTaskTestMixin: def test_clone(self): self.gmp.clone_task("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/tasks/test_create_container_task.py000066400000000000000000000020131466406635600312310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"" b"foo" b'' b"" ) 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( b"" b"foo" b'' b"bar" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/test_create_task.py000066400000000000000000000257121466406635600272020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from collections import OrderedDict from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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( b"" b"foo" b"scan" b'' b'' b'' b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b"bar" b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b'' b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b'' b'' b'' b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b"1" b"" ) self.gmp.create_task( name="foo", config_id="c1", target_id="t1", scanner_id="s1", alterable=False, ) self.connection.send.has_been_called_with( b"" b"foo" b"scan" b'' b'' b'' b"0" b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b"reverse" b"" ) def test_create_task_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgument): 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( b"" b"foo" b"scan" b'' b'' b'' b'' b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b'' b"0" b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b'' b"5" b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b"u1,u2" b"" ) 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( b"" b"foo" b"scan" b'' b'' b'' b"" b"" b"foo" b"bar" b"" b"" b"lorem" b"ipsum" b"" b"" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/tasks/test_delete_task.py000066400000000000000000000013441466406635600271740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteTaskTestMixin: def test_delete(self): self.gmp.delete_task("a1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_task("a1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.delete_task(None) with self.assertRaises(GvmError): self.gmp.delete_task("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/test_get_task.py000066400000000000000000000010461466406635600265100ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpGetTaskTestMixin: def test_get_task(self): self.gmp.get_task("a1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/tasks/test_get_tasks.py000066400000000000000000000037151466406635600267000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetTasksTestMixin: def test_get_tasks_simple(self): self.gmp.get_tasks() self.connection.send.has_been_called_with( b'' ) def test_get_tasks_with_filter_string(self): self.gmp.get_tasks(filter_string="name=foo") self.connection.send.has_been_called_with( b'' ) def test_get_tasks_with_filter_id(self): self.gmp.get_tasks(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_tasks_from_trash(self): self.gmp.get_tasks(trash=True) self.connection.send.has_been_called_with( b'' ) def test_get_tasks_with_details(self): self.gmp.get_tasks(details=True) self.connection.send.has_been_called_with( b'' ) def test_get_tasks_without_details(self): self.gmp.get_tasks(details=False) self.connection.send.has_been_called_with( b'' ) def test_get_tasks_with_schedules_only(self): self.gmp.get_tasks(schedules_only=True) self.connection.send.has_been_called_with( b'' ) def test_get_tasks_with_ignore_pagination(self): self.gmp.get_tasks(ignore_pagination=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_tasks(ignore_pagination=False) self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/test_modify_task.py000066400000000000000000000134511466406635600272230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from collections import OrderedDict from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import HostsOrdering class GmpModifyTaskTestMixin: def test_modify_task(self): self.gmp.modify_task("t1") self.connection.send.has_been_called_with( b'' ) 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( b'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( b'' ) 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( b'' ) 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( b'' ) 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( b'' ) def test_modify_task_with_comment(self): self.gmp.modify_task(task_id="t1", comment="bar") self.connection.send.has_been_called_with( b'' b"bar" b"" ) 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( b'' b'' b'' b'' b"" ) 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( b'' ) def test_modify_task_with_alterable(self): self.gmp.modify_task(task_id="t1", alterable=True) self.connection.send.has_been_called_with( b'' b"1" b"" ) self.gmp.modify_task(task_id="t1", alterable=False) self.connection.send.has_been_called_with( b'' b"0" b"" ) 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( b'' b"reverse" b"" ) def test_modify_task_invalid_hosts_ordering(self): with self.assertRaises(InvalidArgument): 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( b'' ) 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( b'' b"0" b"" ) self.gmp.modify_task(task_id="t1", schedule_periods=5) self.connection.send.has_been_called_with( b'' b"5" b"" ) 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( b'' b"u1,u2" b"" ) 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( b'' b"" b"" b"foo" b"bar" b"" b"" b"lorem" b"ipsum" b"" b"" b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/test_move_task.py000066400000000000000000000012721466406635600267000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpMoveTaskTestMixin: def test_move_task(self): self.gmp.move_task("a1") self.connection.send.has_been_called_with(b'') def test_move_task_to_slave(self): self.gmp.move_task("a1", slave_id="s1") self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.move_task(None) with self.assertRaises(GvmError): self.gmp.move_task("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/test_resume_task.py000066400000000000000000000010171466406635600272270ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpResumeTaskTestMixin: def test_resume_task(self): self.gmp.resume_task("a1") self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.resume_task(None) with self.assertRaises(GvmError): self.gmp.resume_task("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/test_start_task.py000066400000000000000000000007631466406635600270730ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpStartTaskTestMixin: def test_start_task(self): self.gmp.start_task("a1") self.connection.send.has_been_called_with(b'') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.start_task(None) with self.assertRaises(GvmError): self.gmp.start_task("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/tasks/test_stop_task.py000066400000000000000000000007551466406635600267240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpStopTaskTestMixin: def test_stop_task(self): self.gmp.stop_task("a1") self.connection.send.has_been_called_with(b'') def test_missing_id(self): with self.assertRaises(GvmError): self.gmp.stop_task(None) with self.assertRaises(GvmError): self.gmp.stop_task("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_alerts.py000066400000000000000000000020541466406635600250540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .alerts import ( GmpCloneAlertTestMixin, GmpCreateAlertTestMixin, GmpDeleteAlertTestMixin, GmpGetAlertsTestMixin, GmpGetAlertTestMixin, GmpModifyAlertTestMixin, GmpTestAlertTestMixin, GmpTriggerAlertTestMixin, ) class Gmpv224CloneAlertTestCase(GmpCloneAlertTestMixin, Gmpv224TestCase): pass class Gmpv224CreateAlertTestCase(GmpCreateAlertTestMixin, Gmpv224TestCase): pass class Gmpv224DeleteAlertTestCase(GmpDeleteAlertTestMixin, Gmpv224TestCase): pass class Gmpv224GetAlertTestCase(GmpGetAlertTestMixin, Gmpv224TestCase): pass class Gmpv224GetAlertsTestCase(GmpGetAlertsTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyAlertTestCase(GmpModifyAlertTestMixin, Gmpv224TestCase): pass class Gmpv224TestAlertTestCase(GmpTestAlertTestMixin, Gmpv224TestCase): pass class Gmpv224TriggerAlertTestCase(GmpTriggerAlertTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_audits.py000066400000000000000000000022321466406635600250510ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .audits import ( GmpCloneAuditTestMixin, GmpCreateAuditTestMixin, GmpDeleteAuditTestMixin, GmpGetAuditsTestMixin, GmpGetAuditTestMixin, GmpModifyAuditTestMixin, GmpResumeAuditTestMixin, GmpStartAuditTestMixin, GmpStopAuditTestMixin, ) class Gmpv224CloneAuditTestCase(GmpCloneAuditTestMixin, Gmpv224TestCase): pass class Gmpv224CreateAuditTestCase(GmpCreateAuditTestMixin, Gmpv224TestCase): pass class Gmpv224DeleteAuditTestCase(GmpDeleteAuditTestMixin, Gmpv224TestCase): pass class Gmpv224GetAuditTestCase(GmpGetAuditTestMixin, Gmpv224TestCase): pass class Gmpv224GetAuditsTestCase(GmpGetAuditsTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyAuditTestCase(GmpModifyAuditTestMixin, Gmpv224TestCase): pass class Gmpv224ResumeAuditTestCase(GmpResumeAuditTestMixin, Gmpv224TestCase): pass class Gmpv224StartAuditTestCase(GmpStartAuditTestMixin, Gmpv224TestCase): pass class Gmpv224StopAuditTestCase(GmpStopAuditTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_credentials.py000066400000000000000000000017041466406635600260600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .credentials import ( GmpCloneCredentialTestMixin, GmpCreateCredentialTestMixin, GmpDeleteCredentialTestMixin, GmpGetCredentialsTestMixin, GmpGetCredentialTestMixin, GmpModifyCredentialTestMixin, ) class Gmpv224CloneCredentialTestCase( GmpCloneCredentialTestMixin, Gmpv224TestCase ): pass class Gmpv224CreateCredentialTestCase( GmpCreateCredentialTestMixin, Gmpv224TestCase ): pass class Gmpv224DeleteCredentialTestCase( GmpDeleteCredentialTestMixin, Gmpv224TestCase ): pass class Gmpv224GetCredentialTestCase(GmpGetCredentialTestMixin, Gmpv224TestCase): pass class Gmpv224GetCredentialsTestCase( GmpGetCredentialsTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyCredentialTestCase( GmpModifyCredentialTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_filters.py000066400000000000000000000015321466406635600252320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .filters import ( GmpCloneFilterTestMixin, GmpCreateFilterTestMixin, GmpDeleteFilterTestMixin, GmpGetFiltersTestMixin, GmpGetFilterTestMixin, GmpModifyFilterTestMixin, ) class Gmpv224DeleteFilterTestCase(GmpDeleteFilterTestMixin, Gmpv224TestCase): pass class Gmpv224GetFilterTestCase(GmpGetFilterTestMixin, Gmpv224TestCase): pass class Gmpv224GetFiltersTestCase(GmpGetFiltersTestMixin, Gmpv224TestCase): pass class Gmpv224CloneFilterTestCase(GmpCloneFilterTestMixin, Gmpv224TestCase): pass class Gmpv224CreateFilterTestCase(GmpCreateFilterTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyFilterTestCase(GmpModifyFilterTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_groups.py000066400000000000000000000015071466406635600251030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .groups import ( GmpCloneGroupTestMixin, GmpCreateGroupTestMixin, GmpDeleteGroupTestMixin, GmpGetGroupsTestMixin, GmpGetGroupTestMixin, GmpModifyGroupTestMixin, ) class Gmpv224DeleteGroupTestCase(GmpDeleteGroupTestMixin, Gmpv224TestCase): pass class Gmpv224GetGroupTestCase(GmpGetGroupTestMixin, Gmpv224TestCase): pass class Gmpv224GetGroupsTestCase(GmpGetGroupsTestMixin, Gmpv224TestCase): pass class Gmpv224CloneGroupTestCase(GmpCloneGroupTestMixin, Gmpv224TestCase): pass class Gmpv224CreateGroupTestCase(GmpCreateGroupTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyGroupTestCase(GmpModifyGroupTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_hosts.py000066400000000000000000000013061466406635600247210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .hosts import ( GmpCreateHostTestMixin, GmpDeleteHostTestMixin, GmpGetHostsTestMixin, GmpGetHostTestMixin, GmpModifyHostTestMixin, ) class Gmpv224CreateHostTestCase(GmpCreateHostTestMixin, Gmpv224TestCase): pass class Gmpv224DeleteHostTestCase(GmpDeleteHostTestMixin, Gmpv224TestCase): pass class Gmpv224GetHostTestCase(GmpGetHostTestMixin, Gmpv224TestCase): pass class Gmpv224GetHostsTestCase(GmpGetHostsTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyHostTestCase(GmpModifyHostTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_notes.py000066400000000000000000000014641466406635600247160ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .notes import ( GmpCloneNoteTestMixin, GmpCreateNoteTestMixin, GmpDeleteNoteTestMixin, GmpGetNotesTestMixin, GmpGetNoteTestMixin, GmpModifyNoteTestMixin, ) class Gmpv224DeleteNoteTestCase(GmpDeleteNoteTestMixin, Gmpv224TestCase): pass class Gmpv224GetNoteTestCase(GmpGetNoteTestMixin, Gmpv224TestCase): pass class Gmpv224GetNotesTestCase(GmpGetNotesTestMixin, Gmpv224TestCase): pass class Gmpv224CloneNoteTestCase(GmpCloneNoteTestMixin, Gmpv224TestCase): pass class Gmpv224CreateNoteTestCase(GmpCreateNoteTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyNoteTestCase(GmpModifyNoteTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_operating_systems.py000066400000000000000000000013751466406635600273460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .operating_systems import ( GmpDeleteOperatingSystemTestMixin, GmpGetOperatingSystemsTestMixin, GmpGetOperatingSystemTestMixin, GmpModifyOperatingSystemTestMixin, ) class Gmpv224DeleteOperatingSystemTestCase( GmpDeleteOperatingSystemTestMixin, Gmpv224TestCase ): pass class Gmpv224GetOperatingSystemTestCase( GmpGetOperatingSystemTestMixin, Gmpv224TestCase ): pass class Gmpv224GetOperatingSystemsTestCase( GmpGetOperatingSystemsTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyOperatingSystemTestCase( GmpModifyOperatingSystemTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_overrides.py000066400000000000000000000016221466406635600255640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .overrides import ( GmpCloneOverrideTestMixin, GmpCreateOverrideTestMixin, GmpDeleteOverrideTestMixin, GmpGetOverridesTestMixin, GmpGetOverrideTestMixin, GmpModifyOverrideTestMixin, ) class Gmpv224CloneOverrideTestCase(GmpCloneOverrideTestMixin, Gmpv224TestCase): pass class Gmpv224CreateOverrideTestCase( GmpCreateOverrideTestMixin, Gmpv224TestCase ): pass class Gmpv224DeleteOverrideTestCase( GmpDeleteOverrideTestMixin, Gmpv224TestCase ): pass class Gmpv224GetOverrideTestCase(GmpGetOverrideTestMixin, Gmpv224TestCase): pass class Gmpv224GetOverridesTestCase(GmpGetOverridesTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyOverrideTestCase( GmpModifyOverrideTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_permissions.py000066400000000000000000000017041466406635600261360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .permissions import ( GmpClonePermissionTestMixin, GmpCreatePermissionTestMixin, GmpDeletePermissionTestMixin, GmpGetPermissionsTestMixin, GmpGetPermissionTestMixin, GmpModifyPermissionTestMixin, ) class Gmpv224DeletePermissionTestCase( GmpDeletePermissionTestMixin, Gmpv224TestCase ): pass class Gmpv224GetPermissionTestCase(GmpGetPermissionTestMixin, Gmpv224TestCase): pass class Gmpv224GetPermissionsTestCase( GmpGetPermissionsTestMixin, Gmpv224TestCase ): pass class Gmpv224ClonePermissionTestCase( GmpClonePermissionTestMixin, Gmpv224TestCase ): pass class Gmpv224CreatePermissionTestCase( GmpCreatePermissionTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyPermissionTestCase( GmpModifyPermissionTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_policies.py000066400000000000000000000035161466406635600253750ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .policies import ( GmpClonePolicyTestMixin, GmpCreatePolicyTestMixin, GmpDeletePolicyTestMixin, GmpGetPoliciesTestMixin, GmpGetPolicyTestMixin, GmpImportPolicyTestMixin, GmpModifyPolicySetCommentTestMixin, GmpModifyPolicySetFamilySelectionTestMixin, GmpModifyPolicySetNameTestMixin, GmpModifyPolicySetNvtPreferenceTestMixin, GmpModifyPolicySetNvtSelectionTestMixin, GmpModifyPolicySetScannerPreferenceTestMixin, ) class Gmpv224ClonePolicyTestCase(GmpClonePolicyTestMixin, Gmpv224TestCase): pass class Gmpv224CreatePolicyTestCase(GmpCreatePolicyTestMixin, Gmpv224TestCase): pass class Gmpv224DeletePolicyTestCase(GmpDeletePolicyTestMixin, Gmpv224TestCase): pass class Gmpv224GetPolicyTestCase(GmpGetPolicyTestMixin, Gmpv224TestCase): pass class Gmpv224GetPoliciesTestCase(GmpGetPoliciesTestMixin, Gmpv224TestCase): pass class Gmpv224ImportPolicyTestCase(GmpImportPolicyTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyPolicySetCommentTestCase( GmpModifyPolicySetCommentTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyPolicySetFamilySelectionTestCase( GmpModifyPolicySetFamilySelectionTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyPolicySetNvtSelectionTestCase( GmpModifyPolicySetNvtSelectionTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyPolicySetNameTestCase( GmpModifyPolicySetNameTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyPolicySetNvtPreferenceTestCase( GmpModifyPolicySetNvtPreferenceTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyPolicySetScannerPreferenceTestCase( GmpModifyPolicySetScannerPreferenceTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_port_lists.py000066400000000000000000000022431466406635600257640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .port_lists import ( GmpClonePortListTestMixin, GmpCreatePortListTestMixin, GmpCreatePortRangeTestMixin, GmpDeletePortListTestMixin, GmpDeletePortRangeTestMixin, GmpGetPortListsTestMixin, GmpGetPortListTestMixin, GmpModifyPortListTestMixin, ) class Gmpv224ClonePortListTestCase(GmpClonePortListTestMixin, Gmpv224TestCase): pass class Gmpv224CreatePortListTestCase( GmpCreatePortListTestMixin, Gmpv224TestCase ): pass class Gmpv224CreatePortRangeListTestCase( GmpCreatePortRangeTestMixin, Gmpv224TestCase ): pass class Gmpv224DeletePortListTestCase( GmpDeletePortListTestMixin, Gmpv224TestCase ): pass class Gmpv224DeletePortRangeTestCase( GmpDeletePortRangeTestMixin, Gmpv224TestCase ): pass class Gmpv224GetPortListTestCase(GmpGetPortListTestMixin, Gmpv224TestCase): pass class Gmpv224GetPortListsTestCase(GmpGetPortListsTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyPortListTestCase( GmpModifyPortListTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_report_formats.py000066400000000000000000000022001466406635600266210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .report_formats import ( GmpCloneReportFormatTestMixin, GmpDeleteReportFormatTestMixin, GmpGetReportFormatsTestMixin, GmpGetReportFormatTestMixin, GmpImportReportFormatTestMixin, GmpModifyReportFormatTestMixin, GmpVerifyReportFormatTestMixin, ) class Gmpv224DeleteReportFormatTestCase( GmpDeleteReportFormatTestMixin, Gmpv224TestCase ): pass class Gmpv224GetReportFormatTestCase( GmpGetReportFormatTestMixin, Gmpv224TestCase ): pass class Gmpv224GetReportFormatsTestCase( GmpGetReportFormatsTestMixin, Gmpv224TestCase ): pass class Gmpv224CloneReportFormatTestCase( GmpCloneReportFormatTestMixin, Gmpv224TestCase ): pass class Gmpv224ImportReportFormatTestCase( GmpImportReportFormatTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyReportFormatTestCase( GmpModifyReportFormatTestMixin, Gmpv224TestCase ): pass class Gmpv224VerifyReportFormatTestCase( GmpVerifyReportFormatTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_reports.py000066400000000000000000000011571466406635600252630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .reports import ( GmpDeleteReportTestMixin, GmpGetReportsTestMixin, GmpGetReportTestMixin, GmpImportReportTestMixin, ) class Gmpv224DeleteReportTestCase(GmpDeleteReportTestMixin, Gmpv224TestCase): pass class Gmpv224GetReportTestCase(GmpGetReportTestMixin, Gmpv224TestCase): pass class Gmpv224GetReportsTestCase(GmpGetReportsTestMixin, Gmpv224TestCase): pass class Gmpv224ImportReportTestCase(GmpImportReportTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_results.py000066400000000000000000000006011466406635600252570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .results import ( GmpGetResultsTestMixin, GmpGetResultTestMixin, ) class Gmpv224GetResultTestCase(GmpGetResultTestMixin, Gmpv224TestCase): pass class Gmpv224GetResultsTestCase(GmpGetResultsTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_roles.py000066400000000000000000000014641466406635600247120ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .roles import ( GmpCloneRoleTestMixin, GmpCreateRoleTestMixin, GmpDeleteRoleTestMixin, GmpGetRolesTestMixin, GmpGetRoleTestMixin, GmpModifyRoleTestMixin, ) class Gmpv224DeleteRoleTestCase(GmpDeleteRoleTestMixin, Gmpv224TestCase): pass class Gmpv224GetRoleTestCase(GmpGetRoleTestMixin, Gmpv224TestCase): pass class Gmpv224GetRolesTestCase(GmpGetRolesTestMixin, Gmpv224TestCase): pass class Gmpv224CloneRoleTestCase(GmpCloneRoleTestMixin, Gmpv224TestCase): pass class Gmpv224CreateRoleTestCase(GmpCreateRoleTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyRoleTestCase(GmpModifyRoleTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_scan_configs.py000066400000000000000000000037751466406635600262310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .scan_configs import ( GmpCloneScanConfigTestMixin, GmpCreateScanConfigTestMixin, GmpDeleteScanConfigTestMixin, GmpGetScanConfigsTestMixin, GmpGetScanConfigTestMixin, GmpImportScanConfigTestMixin, GmpModifyScanConfigSetCommentTestMixin, GmpModifyScanConfigSetFamilySelectionTestMixin, GmpModifyScanConfigSetNameTestMixin, GmpModifyScanConfigSetNvtPreferenceTestMixin, GmpModifyScanConfigSetNvtSelectionTestMixin, GmpModifyScanConfigSetScannerPreferenceTestMixin, ) class Gmpv224CloneScanConfigTestCase( GmpCloneScanConfigTestMixin, Gmpv224TestCase ): pass class Gmpv224CreateScanConfigTestCase( GmpCreateScanConfigTestMixin, Gmpv224TestCase ): pass class Gmpv224DeleteScanConfigTestCase( GmpDeleteScanConfigTestMixin, Gmpv224TestCase ): pass class Gmpv224GetScanConfigTestCase(GmpGetScanConfigTestMixin, Gmpv224TestCase): pass class Gmpv224GetScanConfigsTestCase( GmpGetScanConfigsTestMixin, Gmpv224TestCase ): pass class Gmpv224ImportScanConfigTestCase( GmpImportScanConfigTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyScanConfigSetCommentTestCase( GmpModifyScanConfigSetCommentTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyScanConfigSetFamilySelectionTestCase( GmpModifyScanConfigSetFamilySelectionTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyScanConfigSetNvtSelectionTestCase( GmpModifyScanConfigSetNvtSelectionTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyScanConfigSetNameTestCase( GmpModifyScanConfigSetNameTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyScanConfigSetNvtPreferenceTestCase( GmpModifyScanConfigSetNvtPreferenceTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyScanConfigSetScannerPreferenceTestCase( GmpModifyScanConfigSetScannerPreferenceTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_scanners.py000066400000000000000000000015551466406635600254030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .scanners import ( GmpCloneScannerTestMixin, GmpCreateScannerTestMixin, GmpDeleteScannerTestMixin, GmpGetScannersTestMixin, GmpGetScannerTestMixin, GmpModifyScannerTestMixin, ) class Gmpv224DeleteScannerTestCase(GmpDeleteScannerTestMixin, Gmpv224TestCase): pass class Gmpv224GetScannerTestCase(GmpGetScannerTestMixin, Gmpv224TestCase): pass class Gmpv224GetScannersTestCase(GmpGetScannersTestMixin, Gmpv224TestCase): pass class Gmpv224CloneScannerTestCase(GmpCloneScannerTestMixin, Gmpv224TestCase): pass class Gmpv224CreateScannerTestCase(GmpCreateScannerTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyScannerTestCase(GmpModifyScannerTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_schedules.py000066400000000000000000000016221466406635600255410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .schedules import ( GmpCloneScheduleTestMixin, GmpCreateScheduleTestMixin, GmpDeleteScheduleTestMixin, GmpGetSchedulesTestMixin, GmpGetScheduleTestMixin, GmpModifyScheduleTestMixin, ) class Gmpv224DeleteScheduleTestCase( GmpDeleteScheduleTestMixin, Gmpv224TestCase ): pass class Gmpv224GetScheduleTestCase(GmpGetScheduleTestMixin, Gmpv224TestCase): pass class Gmpv224GetSchedulesTestCase(GmpGetSchedulesTestMixin, Gmpv224TestCase): pass class Gmpv224CloneScheduleTestCase(GmpCloneScheduleTestMixin, Gmpv224TestCase): pass class Gmpv224CreateScheduleTestCase( GmpCreateScheduleTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyScheduleTestCase( GmpModifyScheduleTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_secinfo.py000066400000000000000000000035701466406635600252140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .secinfo import ( GmpGetCertBundListTestMixin, GmpGetCertBundTestMixin, GmpGetCpeListTestMixin, GmpGetCpeTestMixin, GmpGetCveListTestMixin, GmpGetCveTestMixin, GmpGetDfnCertListTestMixin, GmpGetDfnCertTestMixin, GmpGetInfoListTestMixin, GmpGetInfoTestMixin, GmpGetNvtFamiliesTestMixin, GmpGetNvtListTestMixin, GmpGetNvtTestMixin, GmpGetScanConfigNvtsTestMixin, GmpGetScanConfigNvtTestMixin, ) class Gmpv224GetCertBundTestCase(GmpGetCertBundTestMixin, Gmpv224TestCase): pass class Gmpv224GetCpeTestCase(GmpGetCpeTestMixin, Gmpv224TestCase): pass class Gmpv224GetCveTestCase(GmpGetCveTestMixin, Gmpv224TestCase): pass class Gmpv224GetDfnCertCase(GmpGetDfnCertTestMixin, Gmpv224TestCase): pass class Gmpv224GetInfoListTestCase(GmpGetInfoListTestMixin, Gmpv224TestCase): pass class Gmpv224GetInfoTestCase(GmpGetInfoTestMixin, Gmpv224TestCase): pass class Gmpv224GetNvtTestCase(GmpGetNvtTestMixin, Gmpv224TestCase): pass class Gmpv224GetScanConfigNvtTestCase( GmpGetScanConfigNvtTestMixin, Gmpv224TestCase ): pass class Gmpv224GetNvtFamiliesTestCase( GmpGetNvtFamiliesTestMixin, Gmpv224TestCase ): pass class Gmpv224GetScanConfigNvtsTestCase( GmpGetScanConfigNvtsTestMixin, Gmpv224TestCase ): pass class Gmpv224GetCertBundListTestCase( GmpGetCertBundListTestMixin, Gmpv224TestCase ): pass class Gmpv224GetCpeListTestCase(GmpGetCpeListTestMixin, Gmpv224TestCase): pass class Gmpv224GetCveListTestCase(GmpGetCveListTestMixin, Gmpv224TestCase): pass class Gmpv224GetDfnCertListCase(GmpGetDfnCertListTestMixin, Gmpv224TestCase): pass class Gmpv224GetNvtListTestCase(GmpGetNvtListTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_tags.py000066400000000000000000000014411466406635600245170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .tags import ( GmpCloneTagTestMixin, GmpCreateTagTestMixin, GmpDeleteTagTestMixin, GmpGetTagsTestMixin, GmpGetTagTestMixin, GmpModifyTagTestMixin, ) class Gmpv224DeleteTagTestCase(GmpDeleteTagTestMixin, Gmpv224TestCase): pass class Gmpv224GetTagTestCase(GmpGetTagTestMixin, Gmpv224TestCase): pass class Gmpv224GetTagsTestCase(GmpGetTagsTestMixin, Gmpv224TestCase): pass class Gmpv224CloneTagTestCase(GmpCloneTagTestMixin, Gmpv224TestCase): pass class Gmpv224CreateTagTestCase(GmpCreateTagTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyTagTestCase(GmpModifyTagTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_targets.py000066400000000000000000000015321466406635600252330ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .targets import ( GmpCloneTargetTestMixin, GmpCreateTargetTestMixin, GmpDeleteTargetTestMixin, GmpGetTargetsTestMixin, GmpGetTargetTestMixin, GmpModifyTargetTestMixin, ) class Gmpv224CloneTargetTestCase(GmpCloneTargetTestMixin, Gmpv224TestCase): pass class Gmpv224CreateTargetTestCase(GmpCreateTargetTestMixin, Gmpv224TestCase): pass class Gmpv224DeleteTargetTestCase(GmpDeleteTargetTestMixin, Gmpv224TestCase): pass class Gmpv224GetTargetTestCase(GmpGetTargetTestMixin, Gmpv224TestCase): pass class Gmpv224GetTargetsTestCase(GmpGetTargetsTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyTargetTestCase(GmpModifyTargetTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_tasks.py000066400000000000000000000025731466406635600247150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .tasks import ( GmpCloneTaskTestMixin, GmpCreateContainerTaskTestMixin, GmpCreateTaskTestMixin, GmpDeleteTaskTestMixin, GmpGetTasksTestMixin, GmpGetTaskTestMixin, GmpModifyTaskTestMixin, GmpMoveTaskTestMixin, GmpResumeTaskTestMixin, GmpStartTaskTestMixin, GmpStopTaskTestMixin, ) class Gmpv224CloneTaskTestCase(GmpCloneTaskTestMixin, Gmpv224TestCase): pass class Gmpv224CreateContainerTaskTestCase( GmpCreateContainerTaskTestMixin, Gmpv224TestCase ): pass class Gmpv224CreateTaskTestCase(GmpCreateTaskTestMixin, Gmpv224TestCase): pass class Gmpv224DeleteTaskTestCase(GmpDeleteTaskTestMixin, Gmpv224TestCase): pass class Gmpv224GetTaskTestCase(GmpGetTaskTestMixin, Gmpv224TestCase): pass class Gmpv224GetTasksTestCase(GmpGetTasksTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyTaskTestCase(GmpModifyTaskTestMixin, Gmpv224TestCase): pass class Gmpv224MoveTaskTestCase(GmpMoveTaskTestMixin, Gmpv224TestCase): pass class Gmpv224ResumeTaskTestCase(GmpResumeTaskTestMixin, Gmpv224TestCase): pass class Gmpv224StartTaskTestCase(GmpStartTaskTestMixin, Gmpv224TestCase): pass class Gmpv224StopTaskTestCase(GmpStopTaskTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_tickets.py000066400000000000000000000015321466406635600252300ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .tickets import ( GmpCloneTicketTestMixin, GmpCreateTicketTestMixin, GmpDeleteTicketTestMixin, GmpGetTicketsTestMixin, GmpGetTicketTestMixin, GmpModifyTicketTestMixin, ) class Gmpv224DeleteTicketTestCase(GmpDeleteTicketTestMixin, Gmpv224TestCase): pass class Gmpv224GetTicketTestCase(GmpGetTicketTestMixin, Gmpv224TestCase): pass class Gmpv224GetTicketsTestCase(GmpGetTicketsTestMixin, Gmpv224TestCase): pass class Gmpv224CloneTicketTestCase(GmpCloneTicketTestMixin, Gmpv224TestCase): pass class Gmpv224CreateTicketTestCase(GmpCreateTicketTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyTicketTestCase(GmpModifyTicketTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_tls_certificates.py000066400000000000000000000020271466406635600271110ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .tls_certificates import ( GmpCloneTLSCertificateTestMixin, GmpCreateTLSCertificateTestMixin, GmpDeleteTLSCertificateTestMixin, GmpGetTLSCertificatesTestMixin, GmpGetTLSCertificateTestMixin, GmpModifyTLSCertificateTestMixin, ) class Gmpv224CloneTLSCertificateTestCase( GmpCloneTLSCertificateTestMixin, Gmpv224TestCase ): pass class Gmpv224CreateTLSCertificateTestCase( GmpCreateTLSCertificateTestMixin, Gmpv224TestCase ): pass class Gmpv224DeleteTLSCertificateTestCase( GmpDeleteTLSCertificateTestMixin, Gmpv224TestCase ): pass class Gmpv224GetTLSCertificateTestCase( GmpGetTLSCertificateTestMixin, Gmpv224TestCase ): pass class Gmpv224GetTLSCertificatesTestCase( GmpGetTLSCertificatesTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyTLSCertificateTestCase( GmpModifyTLSCertificateTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_users.py000066400000000000000000000014641466406635600247270ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .users import ( GmpCloneUserTestMixin, GmpCreateUserTestMixin, GmpDeleteUserTestMixin, GmpGetUsersTestMixin, GmpGetUserTestMixin, GmpModifyUserTestMixin, ) class Gmpv224CloneUserTestCase(GmpCloneUserTestMixin, Gmpv224TestCase): pass class Gmpv224CreateUserTestCase(GmpCreateUserTestMixin, Gmpv224TestCase): pass class Gmpv224DeleteUserTestCase(GmpDeleteUserTestMixin, Gmpv224TestCase): pass class Gmpv224GetUserTestCase(GmpGetUserTestMixin, Gmpv224TestCase): pass class Gmpv224GetUsersTestCase(GmpGetUsersTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyUserTestCase(GmpModifyUserTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/test_vulnerabilities.py000066400000000000000000000007021466406635600267610ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .vulnerabilities import ( GmpGetVulnerabilitiesTestMixin, GmpGetVulnerabilityTestMixin, ) class Gmpv224GetVulnerabilityTestCase( GmpGetVulnerabilityTestMixin, Gmpv224TestCase ): pass class Gmpv224GetVulnerabilitiesTestCase( GmpGetVulnerabilitiesTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/entities/tickets/000077500000000000000000000000001466406635600236165ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/tickets/__init__.py000066400000000000000000000011651466406635600257320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneTicketTestMixin", "GmpCreateTicketTestMixin", "GmpDeleteTicketTestMixin", "GmpGetTicketTestMixin", "GmpGetTicketsTestMixin", "GmpModifyTicketTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tickets/test_clone_ticket.py000066400000000000000000000015101466406635600276670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneTicketTestMixin: def test_clone(self): self.gmp.clone_ticket("t1") self.connection.send.has_been_called_with( b"t1" ) self.gmp.clone_ticket(ticket_id="t1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/tickets/test_create_ticket.py000066400000000000000000000034771466406635600300500ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"" b'' b"" b'' b"" b"lorem ipsum" b"" ) 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( b"" b'' b"" b'' b"" b"lorem ipsum" b"bar" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/tickets/test_delete_ticket.py000066400000000000000000000014161466406635600300360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpDeleteTicketTestMixin: def test_delete(self): self.gmp.delete_ticket("t1") self.connection.send.has_been_called_with( b'' ) def test_delete_ultimate(self): self.gmp.delete_ticket("t1", ultimate=True) self.connection.send.has_been_called_with( b'' ) def test_missing_id(self): with self.assertRaises(RequiredArgument): self.gmp.delete_ticket(None) with self.assertRaises(RequiredArgument): self.gmp.delete_ticket("") python-gvm-24.8.0/tests/protocols/gmpv224/entities/tickets/test_get_ticket.py000066400000000000000000000013261466406635600273530ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetTicketTestMixin: def test_get_ticket(self): self.gmp.get_ticket("t1") self.connection.send.has_been_called_with( b'' ) self.gmp.get_ticket(ticket_id="t1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/tickets/test_get_tickets.py000066400000000000000000000017031466406635600275350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetTicketsTestMixin: def test_get_tickets(self): self.gmp.get_tickets() self.connection.send.has_been_called_with(b"") def test_get_tickets_with_filter_string(self): self.gmp.get_tickets(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_tickets_with_filter_id(self): self.gmp.get_tickets(filter_id="f1") self.connection.send.has_been_called_with( b'' ) def test_get_tickets_with_trash(self): self.gmp.get_tickets(trash=True) self.connection.send.has_been_called_with(b'') self.gmp.get_tickets(trash=False) self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/tickets/test_modify_ticket.py000066400000000000000000000062601466406635600300650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 import TicketStatus class GmpModifyTicketTestMixin: def test_modify_ticket(self): self.gmp.modify_ticket("t1") self.connection.send.has_been_called_with( b'' ) self.gmp.modify_ticket(ticket_id="t1") self.connection.send.has_been_called_with( b'' ) 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( b'' b"bar" b"" ) 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( b'' b"" b'' b"" b"" ) def test_modify_ticket_invalid_status(self): with self.assertRaises(InvalidArgument): 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( b'' b"Open" b"lorem ipsum" b"" ) 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( b'' b"Fixed" b"lorem ipsum" b"" ) 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( b'' b"Closed" b"lorem ipsum" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/tls_certificates/000077500000000000000000000000001466406635600254775ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/tls_certificates/__init__.py000066400000000000000000000014131466406635600276070ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneTLSCertificateTestMixin", "GmpCreateTLSCertificateTestMixin", "GmpDeleteTLSCertificateTestMixin", "GmpGetTLSCertificateTestMixin", "GmpGetTLSCertificatesTestMixin", "GmpModifyTLSCertificateTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tls_certificates/test_clone_tls_certificate.py000066400000000000000000000012151466406635600334330ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneTLSCertificateTestMixin: def test_clone(self): self.gmp.clone_tls_certificate("a1") self.connection.send.has_been_called_with( b"" b"a1" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/tls_certificates/test_create_tls_certificate.py000066400000000000000000000027071466406635600336050ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"" b"foo" b"c1" b"bar" b"1" b"" ) self.gmp.create_tls_certificate("foo", "c1", trust=False) self.connection.send.has_been_called_with( b"" b"foo" b"c1" b"0" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/tls_certificates/test_delete_tls_certificate.py000066400000000000000000000013541466406635600336010ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import GvmError class GmpDeleteTLSCertificateTestMixin: def test_delete(self): self.gmp.delete_tls_certificate("a1") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/tls_certificates/test_get_tls_certificate.py000066400000000000000000000012301466406635600331070ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/tls_certificates/test_get_tls_certificates.py000066400000000000000000000020061466406635600332740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetTLSCertificatesTestMixin: def test_get_tls_certificates(self): self.gmp.get_tls_certificates() self.connection.send.has_been_called_with(b"") 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( b'' ) 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( b'' ) def test_get_tls_certificates_with_details(self): self.gmp.get_tls_certificates(details="1") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/tls_certificates/test_modify_tls_certificate.py000066400000000000000000000035661466406635600336350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) def test_modify_tls_certificate_with_name(self): self.gmp.modify_tls_certificate("c1", name="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) def test_modify_tls_certificate_with_comment(self): self.gmp.modify_tls_certificate("c1", comment="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) def test_modify_tls_certificate_with_trust(self): self.gmp.modify_tls_certificate("c1", trust=True) self.connection.send.has_been_called_with( b'' b"1" b"" ) self.gmp.modify_tls_certificate("c1", trust=False) self.connection.send.has_been_called_with( b'' b"0" b"" ) 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-24.8.0/tests/protocols/gmpv224/entities/users/000077500000000000000000000000001466406635600233115ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/users/__init__.py000066400000000000000000000011211466406635600254150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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 __all__ = ( "GmpCloneUserTestMixin", "GmpCreateUserTestMixin", "GmpDeleteUserTestMixin", "GmpGetUserTestMixin", "GmpGetUsersTestMixin", "GmpModifyUserTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/users/test_clone_user.py000066400000000000000000000010541466406635600270600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpCloneUserTestMixin: def test_clone(self): self.gmp.clone_user("a1") self.connection.send.has_been_called_with( b"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-24.8.0/tests/protocols/gmpv224/entities/users/test_create_user.py000066400000000000000000000040431466406635600272240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"foo" ) def test_create_user_with_password(self): self.gmp.create_user(name="foo", password="bar") self.connection.send.has_been_called_with( b"" b"foo" b"bar" b"" ) 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( b"" b"foo" b'h1,h2' b"" ) self.gmp.create_user(name="foo", hosts=["h1", "h2"]) self.connection.send.has_been_called_with( b"" b"foo" b'h1,h2' b"" ) self.gmp.create_user(name="foo", hosts=["h1", "h2"], hosts_allow=False) self.connection.send.has_been_called_with( b"" b"foo" b'h1,h2' b"" ) 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( b"" b"foo" b'' b'' b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/users/test_delete_user.py000066400000000000000000000027011466406635600272220ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) self.gmp.delete_user(user_id="a1") self.connection.send.has_been_called_with( b'' ) def test_delete_user_with_inheritor_id(self): self.gmp.delete_user("a1", inheritor_id="u1") self.connection.send.has_been_called_with( b'' ) def test_delete_user_with_name(self): self.gmp.delete_user(name="foo") self.connection.send.has_been_called_with(b'') def test_delete_user_with_inheritor_name(self): self.gmp.delete_user("a1", inheritor_name="foo") self.connection.send.has_been_called_with( b'' ) 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-24.8.0/tests/protocols/gmpv224/entities/users/test_get_user.py000066400000000000000000000012201466406635600265320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetUserTestMixin: def test_get_user(self): self.gmp.get_user("u1") self.connection.send.has_been_called_with(b'') self.gmp.get_user(user_id="u1") self.connection.send.has_been_called_with(b'') 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-24.8.0/tests/protocols/gmpv224/entities/users/test_get_users.py000066400000000000000000000011711466406635600267220ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetUsersTestMixin: def test_get_users(self): self.gmp.get_users() self.connection.send.has_been_called_with(b"") def test_get_users_with_filter_string(self): self.gmp.get_users(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_users_with_filter_id(self): self.gmp.get_users(filter_id="f1") self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/users/test_modify_user.py000066400000000000000000000106671466406635600272610ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument from gvm.protocols.gmp.requests.v224 import UserAuthType class GmpModifyUserTestMixin: def test_modify_user(self): self.gmp.modify_user(user_id="u1") self.connection.send.has_been_called_with( b'' ) 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( b'' b"foo" b"" ) def test_modify_user_with_new_comment(self): self.gmp.modify_user(user_id="u1", comment="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) def test_modify_user_with_role_ids(self): self.gmp.modify_user(user_id="u1", role_ids=[]) self.connection.send.has_been_called_with( b'' ) self.gmp.modify_user(user_id="u1", role_ids=["r1"]) self.connection.send.has_been_called_with( b'' ) self.gmp.modify_user(user_id="u1", role_ids=["r1", "r2"]) self.connection.send.has_been_called_with( b'' b'' b'' b"" ) def test_modify_user_with_group_ids(self): self.gmp.modify_user(user_id="u1", role_ids=[]) self.connection.send.has_been_called_with( b'' ) self.gmp.modify_user(user_id="u1", group_ids=["r1"]) self.connection.send.has_been_called_with( b'' b'' b"" ) self.gmp.modify_user(user_id="u1", group_ids=["r1", "r2"]) self.connection.send.has_been_called_with( b'' b"" b'' b'' b"" b"" ) def test_modify_user_with_password(self): self.gmp.modify_user(user_id="u1", password="foo") self.connection.send.has_been_called_with( b'' b"foo" b"" ) 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( b'' b"ldap_connect" b"" ) def test_modify_user_with_hosts(self): self.gmp.modify_user(user_id="u1", hosts=[]) self.connection.send.has_been_called_with( b'' ) self.gmp.modify_user(user_id="u1", hosts=["foo"]) self.connection.send.has_been_called_with( b'' b'foo' b"" ) self.gmp.modify_user(user_id="u1", hosts=["foo", "bar"]) self.connection.send.has_been_called_with( b'' b'foo,bar' b"" ) self.gmp.modify_user( user_id="u1", hosts=["foo", "bar"], hosts_allow=False ) self.connection.send.has_been_called_with( b'' b'foo,bar' b"" ) self.gmp.modify_user( user_id="u1", hosts=["foo", "bar"], hosts_allow=True ) self.connection.send.has_been_called_with( b'' b'foo,bar' b"" ) python-gvm-24.8.0/tests/protocols/gmpv224/entities/vulnerabilities/000077500000000000000000000000001466406635600253515ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/entities/vulnerabilities/__init__.py000066400000000000000000000004661466406635600274700ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_vulnerabilities import GmpGetVulnerabilitiesTestMixin from .test_get_vulnerability import GmpGetVulnerabilityTestMixin __all__ = ("GmpGetVulnerabilitiesTestMixin", "GmpGetVulnerabilityTestMixin") python-gvm-24.8.0/tests/protocols/gmpv224/entities/vulnerabilities/test_get_vulnerabilities.py000066400000000000000000000012771466406635600330310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetVulnerabilitiesTestMixin: def test_get_vulnerabilities(self): self.gmp.get_vulnerabilities() self.connection.send.has_been_called_with(b"") def test_get_vulnerabilities_with_filter_string(self): self.gmp.get_vulnerabilities(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) def test_get_vulnerabilities_with_filter_id(self): self.gmp.get_vulnerabilities(filter_id="f1") self.connection.send.has_been_called_with(b'') python-gvm-24.8.0/tests/protocols/gmpv224/entities/vulnerabilities/test_get_vulnerability.py000066400000000000000000000013731466406635600325160ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import RequiredArgument class GmpGetVulnerabilityTestMixin: def test_get_vulnerability(self): self.gmp.get_vulnerability("a1") self.connection.send.has_been_called_with(b'') self.gmp.get_vulnerability(vulnerability_id="a1") self.connection.send.has_been_called_with(b'') 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-24.8.0/tests/protocols/gmpv224/enums/000077500000000000000000000000001466406635600214535ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/enums/__init__.py000066400000000000000000000001411466406635600235600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/protocols/gmpv224/enums/test_aggregate_statistic.py000066400000000000000000000034731466406635600271100ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_alert_condition.py000066400000000000000000000030311466406635600262360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_alert_event.py000066400000000000000000000031071466406635600253750ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_alert_method.py000066400000000000000000000042521466406635600255360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_alive_test.py000066400000000000000000000042461466406635600252310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_credential_format.py000066400000000000000000000023651466406635600265540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 import CredentialFormat class GetCredentialFormatFromStringTestCase(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-24.8.0/tests/protocols/gmpv224/enums/test_credential_type.py000066400000000000000000000032301466406635600262350ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_entity_type.py000066400000000000000000000117161466406635600254470ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_feed_type.py000066400000000000000000000020501466406635600250250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_filter_type.py000066400000000000000000000110111466406635600254040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_help_format.py000066400000000000000000000021621466406635600253650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_hosts_ordering.py000066400000000000000000000017231466406635600261200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_info_type.py000066400000000000000000000026511466406635600250640ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_permission_subject_type.py000066400000000000000000000020761466406635600300410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_port_range_type.py000066400000000000000000000015431466406635600262700ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_report_format_type.py000066400000000000000000000062131466406635600270120ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_scanner_type.py000066400000000000000000000031121466406635600255530ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2020-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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_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-24.8.0/tests/protocols/gmpv224/enums/test_snmp_algorithms.py000066400000000000000000000030521466406635600262720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_sort_order.py000066400000000000000000000015461466406635600252540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_ticket_status.py000066400000000000000000000017461466406635600257620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/enums/test_user_auth_type.py000066400000000000000000000020161466406635600261230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 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-24.8.0/tests/protocols/gmpv224/system/000077500000000000000000000000001466406635600216505ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/__init__.py000066400000000000000000000001411466406635600237550ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/protocols/gmpv224/system/aggregates/000077500000000000000000000000001466406635600237615ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/aggregates/__init__.py000066400000000000000000000003071466406635600260720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_aggregates import GmpGetAggregatesTestMixin __all__ = ("GmpGetAggregatesTestMixin",) python-gvm-24.8.0/tests/protocols/gmpv224/system/aggregates/test_get_aggregates.py000066400000000000000000000257451466406635600303570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, InvalidArgumentType, RequiredArgument from gvm.protocols.gmp.requests.v224 import ( AggregateStatistic, EntityType, 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( b'' ) self.gmp.get_aggregates(resource_type=EntityType.CERT_BUND_ADV) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.CPE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.CVE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.DFN_CERT_ADV) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.HOST) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.NOTE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.NVT) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.OPERATING_SYSTEM) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.OVALDEF) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.OVERRIDE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.REPORT) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.RESULT) self.connection.send.has_been_called_with( b'' ) 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( b'' ) self.gmp.get_aggregates(EntityType.POLICY) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.SCAN_CONFIG) self.connection.send.has_been_called_with( b'' ) self.gmp.get_aggregates(EntityType.TASK) self.connection.send.has_been_called_with( b'' ) 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(InvalidArgument): 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( b'' b'' b'' b'' b"severity" b"" ) 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( b'' b'' b"severity" b"" ) 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( b'' ) 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( b'' b"severity" b"cves" b"" ) self.gmp.get_aggregates( resource_type=EntityType.ALERT, data_columns="severity" ) self.connection.send.has_been_called_with( b'' b"severity" b"" ) 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( b'' ) 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( b'' ) 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( b'' b"name" b"comment" b"" ) self.gmp.get_aggregates( EntityType.SCAN_CONFIG, group_column="uuid", text_columns="name", ) self.connection.send.has_been_called_with( b'' b"name" b"" ) 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( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/system/authentication/000077500000000000000000000000001466406635600246675ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/authentication/__init__.py000066400000000000000000000005651466406635600270060ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_authenticate import GmpAuthenticateTestMixin from .test_describe_auth import GmpDescribeAuthTestMixin from .test_modify_auth import GmpModifyAuthTestMixin __all__ = ( "GmpAuthenticateTestMixin", "GmpDescribeAuthTestMixin", "GmpModifyAuthTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/system/authentication/test_authenticate.py000066400000000000000000000032271466406635600307620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"" b"" b"foo" b"bar" b"" b"" ) self.assertTrue(self.gmp.is_authenticated()) def test_authentication_failure(self): self.connection.read.return_value( b'' ) self.assertFalse(self.gmp.is_authenticated()) self.gmp.authenticate("foo", "bar") self.connection.send.has_been_called_with( b"" b"" b"foo" b"bar" b"" b"" ) self.assertFalse(self.gmp.is_authenticated()) python-gvm-24.8.0/tests/protocols/gmpv224/system/authentication/test_describe_auth.py000066400000000000000000000004161466406635600311020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpDescribeAuthTestMixin: def test_describe_auth(self): self.gmp.describe_auth() self.connection.send.has_been_called_with(b"") python-gvm-24.8.0/tests/protocols/gmpv224/system/authentication/test_modify_auth.py000066400000000000000000000034061466406635600306130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b"" b'' b"" b"foo" b"bar" b"" b"" b"lorem" b"ipsum" b"" b"" b"" ) 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-24.8.0/tests/protocols/gmpv224/system/feed/000077500000000000000000000000001466406635600225535ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/feed/__init__.py000066400000000000000000000003751466406635600246710ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_feed import GmpGetFeedTestMixin from .test_get_feeds import GmpGetFeedsTestMixin __all__ = ("GmpGetFeedTestMixin", "GmpGetFeedsTestMixin") python-gvm-24.8.0/tests/protocols/gmpv224/system/feed/test_get_feed.py000066400000000000000000000030051466406635600257240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v224 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(b'') self.gmp.get_feed(FeedType.CERT) self.connection.send.has_been_called_with(b'') self.gmp.get_feed(FeedType.SCAP) self.connection.send.has_been_called_with(b'') self.gmp.get_feed(FeedType.GVMD_DATA) self.connection.send.has_been_called_with( b'' ) 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(InvalidArgument): self.gmp.get_feed("foo") python-gvm-24.8.0/tests/protocols/gmpv224/system/feed/test_get_feeds.py000066400000000000000000000003761466406635600261170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetFeedsTestMixin: def test_get_feeds(self): self.gmp.get_feeds() self.connection.send.has_been_called_with(b"") python-gvm-24.8.0/tests/protocols/gmpv224/system/help/000077500000000000000000000000001466406635600226005ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/help/__init__.py000066400000000000000000000002531466406635600247110ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_help import GmpHelpTestMixin __all__ = ("GmpHelpTestMixin",) python-gvm-24.8.0/tests/protocols/gmpv224/system/help/test_help.py000066400000000000000000000014531466406635600251440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v224 import HelpFormat class GmpHelpTestMixin: def test_help(self): self.gmp.help() self.connection.send.has_been_called_with(b'') def test_help_type_brief(self): self.gmp.help(brief=True) self.connection.send.has_been_called_with(b'') def test_invalid_help_format(self): with self.assertRaises(InvalidArgument): 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( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/system/system_reports/000077500000000000000000000000001466406635600247525ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/system_reports/__init__.py000066400000000000000000000003211466406635600270570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_system_reports import GmpGetSystemReportsTestMixin __all__ = ("GmpGetSystemReportsTestMixin",) python-gvm-24.8.0/tests/protocols/gmpv224/system/system_reports/test_get_system_reports.py000066400000000000000000000036741466406635600323360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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(b"") def test_get_system_reports_with_name(self): self.gmp.get_system_reports(name="foo") self.connection.send.has_been_called_with( b'' ) def test_get_system_reports_with_slave_id(self): self.gmp.get_system_reports(slave_id="s1") self.connection.send.has_been_called_with( b'' ) def test_get_system_reports_with_brief(self): self.gmp.get_system_reports(brief=True) self.connection.send.has_been_called_with( b'' ) self.gmp.get_system_reports(brief=False) self.connection.send.has_been_called_with( b'' ) def test_get_system_reports_with_duration(self): self.gmp.get_system_reports(duration=3600) self.connection.send.has_been_called_with( b'' ) 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( b'' ) 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( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/system/test_aggregates.py000066400000000000000000000004261466406635600253740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .aggregates import GmpGetAggregatesTestMixin class Gmpv224GetAggregatesTestCase(GmpGetAggregatesTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/system/test_authentication.py000066400000000000000000000010251466406635600262760ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .authentication import ( GmpAuthenticateTestMixin, GmpDescribeAuthTestMixin, GmpModifyAuthTestMixin, ) class Gmpv224AuthenticateTestCase(GmpAuthenticateTestMixin, Gmpv224TestCase): pass class Gmpv224ModifyAuthTestCase(GmpModifyAuthTestMixin, Gmpv224TestCase): pass class Gmpv224DescribeAuthCommandTestCase( GmpDescribeAuthTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/system/test_feed.py000066400000000000000000000005451466406635600241700ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .feed import GmpGetFeedsTestMixin, GmpGetFeedTestMixin class Gmpv224GetFeedTestCase(GmpGetFeedTestMixin, Gmpv224TestCase): pass class Gmpv224GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/system/test_help.py000066400000000000000000000003651466406635600242150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .help import GmpHelpTestMixin class Gmpv224HelpTestCase(GmpHelpTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/system/test_system_reports.py000066400000000000000000000004511466406635600263630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .system_reports import GmpGetSystemReportsTestMixin class Gmpv224GetSystemReportsTestCase( GmpGetSystemReportsTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/system/test_trashcan.py000066400000000000000000000006571466406635600250740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .trashcan import ( GmpEmptyTrashcanTestMixin, GmpRestoreFromTrashcanTestMixin, ) class Gmpv224EmptyTrashcanTestCase(GmpEmptyTrashcanTestMixin, Gmpv224TestCase): pass class Gmpv224RestoreFromTrashcanTestCase( GmpRestoreFromTrashcanTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/system/test_user_settings.py000066400000000000000000000010751466406635600261620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .user_settings import ( GmpGetUserSettingsTestMixin, GmpGetUserSettingTestMixin, GmpModifyUserSettingTestMixin, ) class Gmpv224GetUserSettingTestCase( GmpGetUserSettingTestMixin, Gmpv224TestCase ): pass class Gmpv224GetUserSettingsTestCase( GmpGetUserSettingsTestMixin, Gmpv224TestCase ): pass class Gmpv224ModifyUserSettingTestCase( GmpModifyUserSettingTestMixin, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/system/test_versions.py000066400000000000000000000006341466406635600251340ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224 import Gmpv224TestCase from .versions import GmpGetProtocolVersionTestCase, GmpGetVersionTestCase class Gmpv224GetVersionCommandTestCase(GmpGetVersionTestCase, Gmpv224TestCase): pass class Gmpv224GmpGetProtocolVersionTestCase( GmpGetProtocolVersionTestCase, Gmpv224TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv224/system/trashcan/000077500000000000000000000000001466406635600234535ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/trashcan/__init__.py000066400000000000000000000004611466406635600255650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_empty_trashcan import GmpEmptyTrashcanTestMixin from .test_restore_from_trashcan import GmpRestoreFromTrashcanTestMixin __all__ = ("GmpEmptyTrashcanTestMixin", "GmpRestoreFromTrashcanTestMixin") python-gvm-24.8.0/tests/protocols/gmpv224/system/trashcan/test_empty_trashcan.py000066400000000000000000000004221466406635600301030ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpEmptyTrashcanTestMixin: def test_empty_trashcan(self): self.gmp.empty_trashcan() self.connection.send.has_been_called_with(b"") python-gvm-24.8.0/tests/protocols/gmpv224/system/trashcan/test_restore_from_trashcan.py000066400000000000000000000010671466406635600314610ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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(b'') 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-24.8.0/tests/protocols/gmpv224/system/user_settings/000077500000000000000000000000001466406635600245465ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/user_settings/__init__.py000066400000000000000000000006351466406635600266630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_user_setting import GmpGetUserSettingTestMixin from .test_get_user_settings import GmpGetUserSettingsTestMixin from .test_modify_user_setting import GmpModifyUserSettingTestMixin __all__ = ( "GmpGetUserSettingTestMixin", "GmpGetUserSettingsTestMixin", "GmpModifyUserSettingTestMixin", ) python-gvm-24.8.0/tests/protocols/gmpv224/system/user_settings/test_get_user_setting.py000066400000000000000000000011441466406635600315310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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-24.8.0/tests/protocols/gmpv224/system/user_settings/test_get_user_settings.py000066400000000000000000000007621466406635600317210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetUserSettingsTestMixin: def test_get_settings(self): self.gmp.get_user_settings() self.connection.send.has_been_called_with(b"") def test_get_settings_with_filter_string(self): self.gmp.get_user_settings(filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv224/system/user_settings/test_modify_user_setting.py000066400000000000000000000031721466406635600322440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b"YmFy" b"" ) self.gmp.modify_user_setting(name="s1", value="bar") self.connection.send.has_been_called_with( b"" b"s1" b"YmFy" b"" ) self.gmp.modify_user_setting(setting_id="s1", value="") self.connection.send.has_been_called_with( b'' b"" b"" ) 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-24.8.0/tests/protocols/gmpv224/system/versions/000077500000000000000000000000001466406635600235205ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv224/system/versions/__init__.py000066400000000000000000000004411466406635600256300ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_protocol_version import GmpGetProtocolVersionTestCase from .test_get_version import GmpGetVersionTestCase __all__ = ("GmpGetProtocolVersionTestCase", "GmpGetVersionTestCase") python-gvm-24.8.0/tests/protocols/gmpv224/system/versions/test_get_protocol_version.py000066400000000000000000000003601466406635600313750ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetProtocolVersionTestCase: def test_protocol_version(self): self.assertEqual(self.gmp.get_protocol_version(), (22, 4)) python-gvm-24.8.0/tests/protocols/gmpv224/system/versions/test_get_version.py000066400000000000000000000006251466406635600274600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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(b"") python-gvm-24.8.0/tests/protocols/gmpv224/test_gmp_types.py000066400000000000000000000021621466406635600237450ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.protocols.gmp.requests.v224 import HostsOrdering from . import Gmpv224TestCase class GmpWithStatementTestMixin: def test_types(self): with self.gmp: # Test that the values are equal self.assertEqual( self.gmp.types.AlertEvent.TASK_RUN_STATUS_CHANGED.value, "Task run status changed", ) self.assertEqual( self.gmp.types.PermissionSubjectType.USER.value, "user" ) self.assertEqual( self.gmp.types.HostsOrdering.RANDOM.value, "random" ) # Test usability of from_string self.assertEqual( self.gmp.types.HostsOrdering.from_string("reverse"), self.gmp.types.HostsOrdering.REVERSE, ) # Test, that the Enum class types are equal self.assertEqual(self.gmp.types.HostsOrdering, HostsOrdering) class Gmpv224WithStatementTestCase(GmpWithStatementTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv224/test_with_statement.py000066400000000000000000000010411466406635600247700ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from . import Gmpv224TestCase 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 Gmpv224WithStatementTestCase(GmpWithStatementTestMixin, Gmpv224TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/000077500000000000000000000000001466406635600203255ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv225/__init__.py000066400000000000000000000003431466406635600224360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.protocols.gmp import GMPv225 from .. import GmpTestCase class Gmpv225TestCase(GmpTestCase): gmp_class = GMPv225 python-gvm-24.8.0/tests/protocols/gmpv225/entities/000077500000000000000000000000001466406635600221515ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv225/entities/__init__.py000066400000000000000000000001411466406635600242560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/protocols/gmpv225/entities/resourcenames/000077500000000000000000000000001466406635600250245ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv225/entities/resourcenames/__init__.py000066400000000000000000000004741466406635600271420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_resource_name import GmpGetResourceNameTestMixin from .test_get_resource_names_list import GmpGetResourceNamesListTestMixin __all__ = ("GmpGetResourceNameTestMixin", "GmpGetResourceNamesListTestMixin") python-gvm-24.8.0/tests/protocols/gmpv225/entities/resourcenames/test_get_resource_name.py000066400000000000000000000164571466406635600321400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v225 import ResourceType class GmpGetResourceNameTestMixin: def test_get_resource_name(self): self.gmp.get_resource_name( resource_type=ResourceType.ALERT, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.CERT_BUND_ADV, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.CONFIG, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.CPE, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.CREDENTIAL, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.CVE, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.DFN_CERT_ADV, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.FILTER, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.GROUP, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.HOST, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.NOTE, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.NVT, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.OS, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.PERMISSION, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.PORT_LIST, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.REPORT_FORMAT, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.REPORT, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.RESULT, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.ROLE, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.SCANNER, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.SCHEDULE, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.TARGET, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.TASK, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.TLS_CERTIFICATE, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_name( resource_type=ResourceType.USER, resource_id="i1" ) self.connection.send.has_been_called_with( b'' ) def test_get_resource_name_missing_resource_type(self): with self.assertRaises(RequiredArgument): self.gmp.get_resource_name(resource_id="i1", resource_type=None) with self.assertRaises(RequiredArgument): self.gmp.get_resource_name(resource_id="i1", resource_type="") with self.assertRaises(RequiredArgument): self.gmp.get_resource_name("i1", "") def test_get_resource_name_invalid_resource_type(self): with self.assertRaises(InvalidArgument): self.gmp.get_resource_name(resource_id="i1", resource_type="foo") def test_get_resource_name_missing_resource_id(self): with self.assertRaises(RequiredArgument): self.gmp.get_resource_name( resource_id="", resource_type=ResourceType.CPE ) with self.assertRaises(RequiredArgument): self.gmp.get_resource_name("", resource_type=ResourceType.CPE) with self.assertRaises(RequiredArgument): self.gmp.get_resource_name( resource_id=None, resource_type=ResourceType.CPE ) python-gvm-24.8.0/tests/protocols/gmpv225/entities/resourcenames/test_get_resource_names_list.py000066400000000000000000000132241466406635600333430ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.errors import InvalidArgument, RequiredArgument from gvm.protocols.gmp.requests.v225 import ResourceType class GmpGetResourceNamesListTestMixin: def test_get_resource_names(self): self.gmp.get_resource_names(ResourceType.ALERT) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.CERT_BUND_ADV) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.CONFIG) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(resource_type=ResourceType.CPE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.CREDENTIAL) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.CVE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.DFN_CERT_ADV) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.FILTER) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.GROUP) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.HOST) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.NOTE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.NVT) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.OS) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.OVERRIDE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.PERMISSION) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.PORT_LIST) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.REPORT_FORMAT) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.REPORT) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.RESULT) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.ROLE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.SCANNER) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.SCHEDULE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.TARGET) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.TASK) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.TLS_CERTIFICATE) self.connection.send.has_been_called_with( b'' ) self.gmp.get_resource_names(ResourceType.USER) self.connection.send.has_been_called_with( b'' ) with self.assertRaises(AttributeError): self.gmp.get_resource_names( ResourceType.ALLRESOURCES # pylint: disable=no-member ) def test_get_resource_names_missing_resource_type(self): with self.assertRaises(RequiredArgument): self.gmp.get_resource_names(resource_type=None) with self.assertRaises(RequiredArgument): self.gmp.get_resource_names(resource_type="") with self.assertRaises(RequiredArgument): self.gmp.get_resource_names("") def test_get_resource_names_invalid_resource_type(self): with self.assertRaises(InvalidArgument): self.gmp.get_resource_names(resource_type="foo") def test_get_resource_names_with_filter_string(self): self.gmp.get_resource_names(ResourceType.CPE, filter_string="foo=bar") self.connection.send.has_been_called_with( b'' ) python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_alerts.py000066400000000000000000000020771466406635600250620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.alerts import ( GmpCloneAlertTestMixin, GmpCreateAlertTestMixin, GmpDeleteAlertTestMixin, GmpGetAlertsTestMixin, GmpGetAlertTestMixin, GmpModifyAlertTestMixin, GmpTestAlertTestMixin, GmpTriggerAlertTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneAlertTestCase(GmpCloneAlertTestMixin, Gmpv225TestCase): pass class Gmpv225CreateAlertTestCase(GmpCreateAlertTestMixin, Gmpv225TestCase): pass class Gmpv225DeleteAlertTestCase(GmpDeleteAlertTestMixin, Gmpv225TestCase): pass class Gmpv225GetAlertTestCase(GmpGetAlertTestMixin, Gmpv225TestCase): pass class Gmpv225GetAlertsTestCase(GmpGetAlertsTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyAlertTestCase(GmpModifyAlertTestMixin, Gmpv225TestCase): pass class Gmpv225TestAlertTestCase(GmpTestAlertTestMixin, Gmpv225TestCase): pass class Gmpv225TriggerAlertTestCase(GmpTriggerAlertTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_audits.py000066400000000000000000000022551466406635600250570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.audits import ( GmpCloneAuditTestMixin, GmpCreateAuditTestMixin, GmpDeleteAuditTestMixin, GmpGetAuditsTestMixin, GmpGetAuditTestMixin, GmpModifyAuditTestMixin, GmpResumeAuditTestMixin, GmpStartAuditTestMixin, GmpStopAuditTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneAuditTestCase(GmpCloneAuditTestMixin, Gmpv225TestCase): pass class Gmpv225CreateAuditTestCase(GmpCreateAuditTestMixin, Gmpv225TestCase): pass class Gmpv225DeleteAuditTestCase(GmpDeleteAuditTestMixin, Gmpv225TestCase): pass class Gmpv225GetAuditTestCase(GmpGetAuditTestMixin, Gmpv225TestCase): pass class Gmpv225GetAuditsTestCase(GmpGetAuditsTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyAuditTestCase(GmpModifyAuditTestMixin, Gmpv225TestCase): pass class Gmpv225ResumeAuditTestCase(GmpResumeAuditTestMixin, Gmpv225TestCase): pass class Gmpv225StartAuditTestCase(GmpStartAuditTestMixin, Gmpv225TestCase): pass class Gmpv225StopAuditTestCase(GmpStopAuditTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_credentials.py000066400000000000000000000017271466406635600260660ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.credentials import ( GmpCloneCredentialTestMixin, GmpCreateCredentialTestMixin, GmpDeleteCredentialTestMixin, GmpGetCredentialsTestMixin, GmpGetCredentialTestMixin, GmpModifyCredentialTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneCredentialTestCase( GmpCloneCredentialTestMixin, Gmpv225TestCase ): pass class Gmpv225CreateCredentialTestCase( GmpCreateCredentialTestMixin, Gmpv225TestCase ): pass class Gmpv225DeleteCredentialTestCase( GmpDeleteCredentialTestMixin, Gmpv225TestCase ): pass class Gmpv225GetCredentialTestCase(GmpGetCredentialTestMixin, Gmpv225TestCase): pass class Gmpv225GetCredentialsTestCase( GmpGetCredentialsTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyCredentialTestCase( GmpModifyCredentialTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_filters.py000066400000000000000000000015551466406635600252400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.filters import ( GmpCloneFilterTestMixin, GmpCreateFilterTestMixin, GmpDeleteFilterTestMixin, GmpGetFiltersTestMixin, GmpGetFilterTestMixin, GmpModifyFilterTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteFilterTestCase(GmpDeleteFilterTestMixin, Gmpv225TestCase): pass class Gmpv225GetFilterTestCase(GmpGetFilterTestMixin, Gmpv225TestCase): pass class Gmpv225GetFiltersTestCase(GmpGetFiltersTestMixin, Gmpv225TestCase): pass class Gmpv225CloneFilterTestCase(GmpCloneFilterTestMixin, Gmpv225TestCase): pass class Gmpv225CreateFilterTestCase(GmpCreateFilterTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyFilterTestCase(GmpModifyFilterTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_groups.py000066400000000000000000000015321466406635600251020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.groups import ( GmpCloneGroupTestMixin, GmpCreateGroupTestMixin, GmpDeleteGroupTestMixin, GmpGetGroupsTestMixin, GmpGetGroupTestMixin, GmpModifyGroupTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteGroupTestCase(GmpDeleteGroupTestMixin, Gmpv225TestCase): pass class Gmpv225GetGroupTestCase(GmpGetGroupTestMixin, Gmpv225TestCase): pass class Gmpv225GetGroupsTestCase(GmpGetGroupsTestMixin, Gmpv225TestCase): pass class Gmpv225CloneGroupTestCase(GmpCloneGroupTestMixin, Gmpv225TestCase): pass class Gmpv225CreateGroupTestCase(GmpCreateGroupTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyGroupTestCase(GmpModifyGroupTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_hosts.py000066400000000000000000000013311466406635600247200ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.hosts import ( GmpCreateHostTestMixin, GmpDeleteHostTestMixin, GmpGetHostsTestMixin, GmpGetHostTestMixin, GmpModifyHostTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CreateHostTestCase(GmpCreateHostTestMixin, Gmpv225TestCase): pass class Gmpv225DeleteHostTestCase(GmpDeleteHostTestMixin, Gmpv225TestCase): pass class Gmpv225GetHostTestCase(GmpGetHostTestMixin, Gmpv225TestCase): pass class Gmpv225GetHostsTestCase(GmpGetHostsTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyHostTestCase(GmpModifyHostTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_notes.py000066400000000000000000000015071466406635600247150ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.notes import ( GmpCloneNoteTestMixin, GmpCreateNoteTestMixin, GmpDeleteNoteTestMixin, GmpGetNotesTestMixin, GmpGetNoteTestMixin, GmpModifyNoteTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteNoteTestCase(GmpDeleteNoteTestMixin, Gmpv225TestCase): pass class Gmpv225GetNoteTestCase(GmpGetNoteTestMixin, Gmpv225TestCase): pass class Gmpv225GetNotesTestCase(GmpGetNotesTestMixin, Gmpv225TestCase): pass class Gmpv225CloneNoteTestCase(GmpCloneNoteTestMixin, Gmpv225TestCase): pass class Gmpv225CreateNoteTestCase(GmpCreateNoteTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyNoteTestCase(GmpModifyNoteTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_operating_systems.py000066400000000000000000000014201466406635600273360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.operating_systems import ( GmpDeleteOperatingSystemTestMixin, GmpGetOperatingSystemsTestMixin, GmpGetOperatingSystemTestMixin, GmpModifyOperatingSystemTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteOperatingSystemTestCase( GmpDeleteOperatingSystemTestMixin, Gmpv225TestCase ): pass class Gmpv225GetOperatingSystemTestCase( GmpGetOperatingSystemTestMixin, Gmpv225TestCase ): pass class Gmpv225GetOperatingSystemsTestCase( GmpGetOperatingSystemsTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyOperatingSystemTestCase( GmpModifyOperatingSystemTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_overrides.py000066400000000000000000000016451466406635600255720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.overrides import ( GmpCloneOverrideTestMixin, GmpCreateOverrideTestMixin, GmpDeleteOverrideTestMixin, GmpGetOverridesTestMixin, GmpGetOverrideTestMixin, GmpModifyOverrideTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneOverrideTestCase(GmpCloneOverrideTestMixin, Gmpv225TestCase): pass class Gmpv225CreateOverrideTestCase( GmpCreateOverrideTestMixin, Gmpv225TestCase ): pass class Gmpv225DeleteOverrideTestCase( GmpDeleteOverrideTestMixin, Gmpv225TestCase ): pass class Gmpv225GetOverrideTestCase(GmpGetOverrideTestMixin, Gmpv225TestCase): pass class Gmpv225GetOverridesTestCase(GmpGetOverridesTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyOverrideTestCase( GmpModifyOverrideTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_permissions.py000066400000000000000000000017271466406635600261440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.permissions import ( GmpClonePermissionTestMixin, GmpCreatePermissionTestMixin, GmpDeletePermissionTestMixin, GmpGetPermissionsTestMixin, GmpGetPermissionTestMixin, GmpModifyPermissionTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeletePermissionTestCase( GmpDeletePermissionTestMixin, Gmpv225TestCase ): pass class Gmpv225GetPermissionTestCase(GmpGetPermissionTestMixin, Gmpv225TestCase): pass class Gmpv225GetPermissionsTestCase( GmpGetPermissionsTestMixin, Gmpv225TestCase ): pass class Gmpv225ClonePermissionTestCase( GmpClonePermissionTestMixin, Gmpv225TestCase ): pass class Gmpv225CreatePermissionTestCase( GmpCreatePermissionTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyPermissionTestCase( GmpModifyPermissionTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_policies.py000066400000000000000000000035411466406635600253740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.policies import ( GmpClonePolicyTestMixin, GmpCreatePolicyTestMixin, GmpDeletePolicyTestMixin, GmpGetPoliciesTestMixin, GmpGetPolicyTestMixin, GmpImportPolicyTestMixin, GmpModifyPolicySetCommentTestMixin, GmpModifyPolicySetFamilySelectionTestMixin, GmpModifyPolicySetNameTestMixin, GmpModifyPolicySetNvtPreferenceTestMixin, GmpModifyPolicySetNvtSelectionTestMixin, GmpModifyPolicySetScannerPreferenceTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225ClonePolicyTestCase(GmpClonePolicyTestMixin, Gmpv225TestCase): pass class Gmpv225CreatePolicyTestCase(GmpCreatePolicyTestMixin, Gmpv225TestCase): pass class Gmpv225DeletePolicyTestCase(GmpDeletePolicyTestMixin, Gmpv225TestCase): pass class Gmpv225GetPolicyTestCase(GmpGetPolicyTestMixin, Gmpv225TestCase): pass class Gmpv225GetPoliciesTestCase(GmpGetPoliciesTestMixin, Gmpv225TestCase): pass class Gmpv225ImportPolicyTestCase(GmpImportPolicyTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyPolicySetCommentTestCase( GmpModifyPolicySetCommentTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyPolicySetFamilySelectionTestCase( GmpModifyPolicySetFamilySelectionTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyPolicySetNvtSelectionTestCase( GmpModifyPolicySetNvtSelectionTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyPolicySetNameTestCase( GmpModifyPolicySetNameTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyPolicySetNvtPreferenceTestCase( GmpModifyPolicySetNvtPreferenceTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyPolicySetScannerPreferenceTestCase( GmpModifyPolicySetScannerPreferenceTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_port_lists.py000066400000000000000000000022661466406635600257720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.port_lists import ( GmpClonePortListTestMixin, GmpCreatePortListTestMixin, GmpCreatePortRangeTestMixin, GmpDeletePortListTestMixin, GmpDeletePortRangeTestMixin, GmpGetPortListsTestMixin, GmpGetPortListTestMixin, GmpModifyPortListTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225ClonePortListTestCase(GmpClonePortListTestMixin, Gmpv225TestCase): pass class Gmpv225CreatePortListTestCase( GmpCreatePortListTestMixin, Gmpv225TestCase ): pass class Gmpv225CreatePortRangeListTestCase( GmpCreatePortRangeTestMixin, Gmpv225TestCase ): pass class Gmpv225DeletePortListTestCase( GmpDeletePortListTestMixin, Gmpv225TestCase ): pass class Gmpv225DeletePortRangeTestCase( GmpDeletePortRangeTestMixin, Gmpv225TestCase ): pass class Gmpv225GetPortListTestCase(GmpGetPortListTestMixin, Gmpv225TestCase): pass class Gmpv225GetPortListsTestCase(GmpGetPortListsTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyPortListTestCase( GmpModifyPortListTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_report_formats.py000066400000000000000000000022231466406635600266270ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.report_formats import ( GmpCloneReportFormatTestMixin, GmpDeleteReportFormatTestMixin, GmpGetReportFormatsTestMixin, GmpGetReportFormatTestMixin, GmpImportReportFormatTestMixin, GmpModifyReportFormatTestMixin, GmpVerifyReportFormatTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteReportFormatTestCase( GmpDeleteReportFormatTestMixin, Gmpv225TestCase ): pass class Gmpv225GetReportFormatTestCase( GmpGetReportFormatTestMixin, Gmpv225TestCase ): pass class Gmpv225GetReportFormatsTestCase( GmpGetReportFormatsTestMixin, Gmpv225TestCase ): pass class Gmpv225CloneReportFormatTestCase( GmpCloneReportFormatTestMixin, Gmpv225TestCase ): pass class Gmpv225ImportReportFormatTestCase( GmpImportReportFormatTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyReportFormatTestCase( GmpModifyReportFormatTestMixin, Gmpv225TestCase ): pass class Gmpv225VerifyReportFormatTestCase( GmpVerifyReportFormatTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_reports.py000066400000000000000000000012021466406635600252530ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.reports import ( GmpDeleteReportTestMixin, GmpGetReportsTestMixin, GmpGetReportTestMixin, GmpImportReportTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteReportTestCase(GmpDeleteReportTestMixin, Gmpv225TestCase): pass class Gmpv225GetReportTestCase(GmpGetReportTestMixin, Gmpv225TestCase): pass class Gmpv225GetReportsTestCase(GmpGetReportsTestMixin, Gmpv225TestCase): pass class Gmpv225ImportReportTestCase(GmpImportReportTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_resource_names.py000066400000000000000000000007031466406635600265740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv225 import Gmpv225TestCase from .resourcenames import ( GmpGetResourceNamesListTestMixin, GmpGetResourceNameTestMixin, ) class Gmpv225GetResourceNamesListTestCase( GmpGetResourceNamesListTestMixin, Gmpv225TestCase ): pass class Gmpv225GetResourceNameTestCase( GmpGetResourceNameTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_results.py000066400000000000000000000006241466406635600252650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.results import ( GmpGetResultsTestMixin, GmpGetResultTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225GetResultTestCase(GmpGetResultTestMixin, Gmpv225TestCase): pass class Gmpv225GetResultsTestCase(GmpGetResultsTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_roles.py000066400000000000000000000015071466406635600247110ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.roles import ( GmpCloneRoleTestMixin, GmpCreateRoleTestMixin, GmpDeleteRoleTestMixin, GmpGetRolesTestMixin, GmpGetRoleTestMixin, GmpModifyRoleTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteRoleTestCase(GmpDeleteRoleTestMixin, Gmpv225TestCase): pass class Gmpv225GetRoleTestCase(GmpGetRoleTestMixin, Gmpv225TestCase): pass class Gmpv225GetRolesTestCase(GmpGetRolesTestMixin, Gmpv225TestCase): pass class Gmpv225CloneRoleTestCase(GmpCloneRoleTestMixin, Gmpv225TestCase): pass class Gmpv225CreateRoleTestCase(GmpCreateRoleTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyRoleTestCase(GmpModifyRoleTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_scan_configs.py000066400000000000000000000040201466406635600262120ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.scan_configs import ( GmpCloneScanConfigTestMixin, GmpCreateScanConfigTestMixin, GmpDeleteScanConfigTestMixin, GmpGetScanConfigsTestMixin, GmpGetScanConfigTestMixin, GmpImportScanConfigTestMixin, GmpModifyScanConfigSetCommentTestMixin, GmpModifyScanConfigSetFamilySelectionTestMixin, GmpModifyScanConfigSetNameTestMixin, GmpModifyScanConfigSetNvtPreferenceTestMixin, GmpModifyScanConfigSetNvtSelectionTestMixin, GmpModifyScanConfigSetScannerPreferenceTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneScanConfigTestCase( GmpCloneScanConfigTestMixin, Gmpv225TestCase ): pass class Gmpv225CreateScanConfigTestCase( GmpCreateScanConfigTestMixin, Gmpv225TestCase ): pass class Gmpv225DeleteScanConfigTestCase( GmpDeleteScanConfigTestMixin, Gmpv225TestCase ): pass class Gmpv225GetScanConfigTestCase(GmpGetScanConfigTestMixin, Gmpv225TestCase): pass class Gmpv225GetScanConfigsTestCase( GmpGetScanConfigsTestMixin, Gmpv225TestCase ): pass class Gmpv225ImportScanConfigTestCase( GmpImportScanConfigTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyScanConfigSetCommentTestCase( GmpModifyScanConfigSetCommentTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyScanConfigSetFamilySelectionTestCase( GmpModifyScanConfigSetFamilySelectionTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyScanConfigSetNvtSelectionTestCase( GmpModifyScanConfigSetNvtSelectionTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyScanConfigSetNameTestCase( GmpModifyScanConfigSetNameTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyScanConfigSetNvtPreferenceTestCase( GmpModifyScanConfigSetNvtPreferenceTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyScanConfigSetScannerPreferenceTestCase( GmpModifyScanConfigSetScannerPreferenceTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_scanners.py000066400000000000000000000016001466406635600253730ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.scanners import ( GmpCloneScannerTestMixin, GmpCreateScannerTestMixin, GmpDeleteScannerTestMixin, GmpGetScannersTestMixin, GmpGetScannerTestMixin, GmpModifyScannerTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteScannerTestCase(GmpDeleteScannerTestMixin, Gmpv225TestCase): pass class Gmpv225GetScannerTestCase(GmpGetScannerTestMixin, Gmpv225TestCase): pass class Gmpv225GetScannersTestCase(GmpGetScannersTestMixin, Gmpv225TestCase): pass class Gmpv225CloneScannerTestCase(GmpCloneScannerTestMixin, Gmpv225TestCase): pass class Gmpv225CreateScannerTestCase(GmpCreateScannerTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyScannerTestCase(GmpModifyScannerTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_schedules.py000066400000000000000000000016451466406635600255470ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.schedules import ( GmpCloneScheduleTestMixin, GmpCreateScheduleTestMixin, GmpDeleteScheduleTestMixin, GmpGetSchedulesTestMixin, GmpGetScheduleTestMixin, GmpModifyScheduleTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteScheduleTestCase( GmpDeleteScheduleTestMixin, Gmpv225TestCase ): pass class Gmpv225GetScheduleTestCase(GmpGetScheduleTestMixin, Gmpv225TestCase): pass class Gmpv225GetSchedulesTestCase(GmpGetSchedulesTestMixin, Gmpv225TestCase): pass class Gmpv225CloneScheduleTestCase(GmpCloneScheduleTestMixin, Gmpv225TestCase): pass class Gmpv225CreateScheduleTestCase( GmpCreateScheduleTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyScheduleTestCase( GmpModifyScheduleTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_secinfo.py000066400000000000000000000036131466406635600252130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.secinfo import ( GmpGetCertBundListTestMixin, GmpGetCertBundTestMixin, GmpGetCpeListTestMixin, GmpGetCpeTestMixin, GmpGetCveListTestMixin, GmpGetCveTestMixin, GmpGetDfnCertListTestMixin, GmpGetDfnCertTestMixin, GmpGetInfoListTestMixin, GmpGetInfoTestMixin, GmpGetNvtFamiliesTestMixin, GmpGetNvtListTestMixin, GmpGetNvtTestMixin, GmpGetScanConfigNvtsTestMixin, GmpGetScanConfigNvtTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225GetCertBundTestCase(GmpGetCertBundTestMixin, Gmpv225TestCase): pass class Gmpv225GetCpeTestCase(GmpGetCpeTestMixin, Gmpv225TestCase): pass class Gmpv225GetCveTestCase(GmpGetCveTestMixin, Gmpv225TestCase): pass class Gmpv225GetDfnCertCase(GmpGetDfnCertTestMixin, Gmpv225TestCase): pass class Gmpv225GetInfoListTestCase(GmpGetInfoListTestMixin, Gmpv225TestCase): pass class Gmpv225GetInfoTestCase(GmpGetInfoTestMixin, Gmpv225TestCase): pass class Gmpv225GetNvtTestCase(GmpGetNvtTestMixin, Gmpv225TestCase): pass class Gmpv225GetScanConfigNvtTestCase( GmpGetScanConfigNvtTestMixin, Gmpv225TestCase ): pass class Gmpv225GetNvtFamiliesTestCase( GmpGetNvtFamiliesTestMixin, Gmpv225TestCase ): pass class Gmpv225GetScanConfigNvtsTestCase( GmpGetScanConfigNvtsTestMixin, Gmpv225TestCase ): pass class Gmpv225GetCertBundListTestCase( GmpGetCertBundListTestMixin, Gmpv225TestCase ): pass class Gmpv225GetCpeListTestCase(GmpGetCpeListTestMixin, Gmpv225TestCase): pass class Gmpv225GetCveListTestCase(GmpGetCveListTestMixin, Gmpv225TestCase): pass class Gmpv225GetDfnCertListCase(GmpGetDfnCertListTestMixin, Gmpv225TestCase): pass class Gmpv225GetNvtListTestCase(GmpGetNvtListTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_tags.py000066400000000000000000000014641466406635600245250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.tags import ( GmpCloneTagTestMixin, GmpCreateTagTestMixin, GmpDeleteTagTestMixin, GmpGetTagsTestMixin, GmpGetTagTestMixin, GmpModifyTagTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteTagTestCase(GmpDeleteTagTestMixin, Gmpv225TestCase): pass class Gmpv225GetTagTestCase(GmpGetTagTestMixin, Gmpv225TestCase): pass class Gmpv225GetTagsTestCase(GmpGetTagsTestMixin, Gmpv225TestCase): pass class Gmpv225CloneTagTestCase(GmpCloneTagTestMixin, Gmpv225TestCase): pass class Gmpv225CreateTagTestCase(GmpCreateTagTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyTagTestCase(GmpModifyTagTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_targets.py000066400000000000000000000015551466406635600252410ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.targets import ( GmpCloneTargetTestMixin, GmpCreateTargetTestMixin, GmpDeleteTargetTestMixin, GmpGetTargetsTestMixin, GmpGetTargetTestMixin, GmpModifyTargetTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneTargetTestCase(GmpCloneTargetTestMixin, Gmpv225TestCase): pass class Gmpv225CreateTargetTestCase(GmpCreateTargetTestMixin, Gmpv225TestCase): pass class Gmpv225DeleteTargetTestCase(GmpDeleteTargetTestMixin, Gmpv225TestCase): pass class Gmpv225GetTargetTestCase(GmpGetTargetTestMixin, Gmpv225TestCase): pass class Gmpv225GetTargetsTestCase(GmpGetTargetsTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyTargetTestCase(GmpModifyTargetTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_tasks.py000066400000000000000000000026161466406635600247140ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.tasks import ( GmpCloneTaskTestMixin, GmpCreateContainerTaskTestMixin, GmpCreateTaskTestMixin, GmpDeleteTaskTestMixin, GmpGetTasksTestMixin, GmpGetTaskTestMixin, GmpModifyTaskTestMixin, GmpMoveTaskTestMixin, GmpResumeTaskTestMixin, GmpStartTaskTestMixin, GmpStopTaskTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneTaskTestCase(GmpCloneTaskTestMixin, Gmpv225TestCase): pass class Gmpv225CreateContainerTaskTestCase( GmpCreateContainerTaskTestMixin, Gmpv225TestCase ): pass class Gmpv225CreateTaskTestCase(GmpCreateTaskTestMixin, Gmpv225TestCase): pass class Gmpv225DeleteTaskTestCase(GmpDeleteTaskTestMixin, Gmpv225TestCase): pass class Gmpv225GetTaskTestCase(GmpGetTaskTestMixin, Gmpv225TestCase): pass class Gmpv225GetTasksTestCase(GmpGetTasksTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyTaskTestCase(GmpModifyTaskTestMixin, Gmpv225TestCase): pass class Gmpv225MoveTaskTestCase(GmpMoveTaskTestMixin, Gmpv225TestCase): pass class Gmpv225ResumeTaskTestCase(GmpResumeTaskTestMixin, Gmpv225TestCase): pass class Gmpv225StartTaskTestCase(GmpStartTaskTestMixin, Gmpv225TestCase): pass class Gmpv225StopTaskTestCase(GmpStopTaskTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_tickets.py000066400000000000000000000015551466406635600252360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.tickets import ( GmpCloneTicketTestMixin, GmpCreateTicketTestMixin, GmpDeleteTicketTestMixin, GmpGetTicketsTestMixin, GmpGetTicketTestMixin, GmpModifyTicketTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225DeleteTicketTestCase(GmpDeleteTicketTestMixin, Gmpv225TestCase): pass class Gmpv225GetTicketTestCase(GmpGetTicketTestMixin, Gmpv225TestCase): pass class Gmpv225GetTicketsTestCase(GmpGetTicketsTestMixin, Gmpv225TestCase): pass class Gmpv225CloneTicketTestCase(GmpCloneTicketTestMixin, Gmpv225TestCase): pass class Gmpv225CreateTicketTestCase(GmpCreateTicketTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyTicketTestCase(GmpModifyTicketTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_tls_certificates.py000066400000000000000000000020521466406635600271100ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.tls_certificates import ( GmpCloneTLSCertificateTestMixin, GmpCreateTLSCertificateTestMixin, GmpDeleteTLSCertificateTestMixin, GmpGetTLSCertificatesTestMixin, GmpGetTLSCertificateTestMixin, GmpModifyTLSCertificateTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneTLSCertificateTestCase( GmpCloneTLSCertificateTestMixin, Gmpv225TestCase ): pass class Gmpv225CreateTLSCertificateTestCase( GmpCreateTLSCertificateTestMixin, Gmpv225TestCase ): pass class Gmpv225DeleteTLSCertificateTestCase( GmpDeleteTLSCertificateTestMixin, Gmpv225TestCase ): pass class Gmpv225GetTLSCertificateTestCase( GmpGetTLSCertificateTestMixin, Gmpv225TestCase ): pass class Gmpv225GetTLSCertificatesTestCase( GmpGetTLSCertificatesTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyTLSCertificateTestCase( GmpModifyTLSCertificateTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_users.py000066400000000000000000000015071466406635600247260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.users import ( GmpCloneUserTestMixin, GmpCreateUserTestMixin, GmpDeleteUserTestMixin, GmpGetUsersTestMixin, GmpGetUserTestMixin, GmpModifyUserTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225CloneUserTestCase(GmpCloneUserTestMixin, Gmpv225TestCase): pass class Gmpv225CreateUserTestCase(GmpCreateUserTestMixin, Gmpv225TestCase): pass class Gmpv225DeleteUserTestCase(GmpDeleteUserTestMixin, Gmpv225TestCase): pass class Gmpv225GetUserTestCase(GmpGetUserTestMixin, Gmpv225TestCase): pass class Gmpv225GetUsersTestCase(GmpGetUsersTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyUserTestCase(GmpModifyUserTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/entities/test_vulnerabilities.py000066400000000000000000000007251466406635600267670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.entities.vulnerabilities import ( GmpGetVulnerabilitiesTestMixin, GmpGetVulnerabilityTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225GetVulnerabilityTestCase( GmpGetVulnerabilityTestMixin, Gmpv225TestCase ): pass class Gmpv225GetVulnerabilitiesTestCase( GmpGetVulnerabilitiesTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/enums/000077500000000000000000000000001466406635600214545ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv225/enums/__init__.py000066400000000000000000000001411466406635600235610ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/protocols/gmpv225/enums/test_aggregate_statistic.py000066400000000000000000000034731466406635600271110ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_alert_condition.py000066400000000000000000000030311466406635600262370ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_alert_event.py000066400000000000000000000031071466406635600253760ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_alert_method.py000066400000000000000000000042521466406635600255370ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_alive_test.py000066400000000000000000000042461466406635600252320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_credential_format.py000066400000000000000000000023651466406635600265550ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 import CredentialFormat class GetCredentialFormatFromStringTestCase(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-24.8.0/tests/protocols/gmpv225/enums/test_credential_type.py000066400000000000000000000032301466406635600262360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_entity_type.py000066400000000000000000000117161466406635600254500ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_feed_type.py000066400000000000000000000020501466406635600250260ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_filter_type.py000066400000000000000000000110111466406635600254050ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_help_format.py000066400000000000000000000021621466406635600253660ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_hosts_ordering.py000066400000000000000000000017231466406635600261210ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_info_type.py000066400000000000000000000026511466406635600250650ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_permission_subject_type.py000066400000000000000000000020761466406635600300420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_port_range_type.py000066400000000000000000000015431466406635600262710ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_report_format_type.py000066400000000000000000000062131466406635600270130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_resource_type.py000066400000000000000000000100001466406635600257440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 import ResourceType class GetResourceTypeFromStringTestCase(unittest.TestCase): def test_invalid(self): with self.assertRaises(InvalidArgument): ResourceType.from_string("foo") def test_none_or_empty(self): ct = ResourceType.from_string(None) self.assertIsNone(ct) ct = ResourceType.from_string("") self.assertIsNone(ct) def test_alert(self): ct = ResourceType.from_string("alert") self.assertEqual(ct, ResourceType.ALERT) def test_cert_bund_adv(self): ct = ResourceType.from_string("cert_bund_adv") self.assertEqual(ct, ResourceType.CERT_BUND_ADV) def test_config(self): ct = ResourceType.from_string("config") self.assertEqual(ct, ResourceType.CONFIG) def test_cpe(self): ct = ResourceType.from_string("cpe") self.assertEqual(ct, ResourceType.CPE) def test_credential(self): ct = ResourceType.from_string("credential") self.assertEqual(ct, ResourceType.CREDENTIAL) def test_cve(self): ct = ResourceType.from_string("cve") self.assertEqual(ct, ResourceType.CVE) def test_dfn_cert_adv(self): ct = ResourceType.from_string("dfn_cert_adv") self.assertEqual(ct, ResourceType.DFN_CERT_ADV) def test_filter(self): ct = ResourceType.from_string("filter") self.assertEqual(ct, ResourceType.FILTER) def test_group(self): ct = ResourceType.from_string("group") self.assertEqual(ct, ResourceType.GROUP) def test_host(self): ct = ResourceType.from_string("host") self.assertEqual(ct, ResourceType.HOST) def test_note(self): ct = ResourceType.from_string("note") self.assertEqual(ct, ResourceType.NOTE) def test_nvt(self): ct = ResourceType.from_string("nvt") self.assertEqual(ct, ResourceType.NVT) def test_os(self): ct = ResourceType.from_string("os") self.assertEqual(ct, ResourceType.OS) def test_override(self): ct = ResourceType.from_string("override") self.assertEqual(ct, ResourceType.OVERRIDE) def test_permission(self): ct = ResourceType.from_string("permission") self.assertEqual(ct, ResourceType.PERMISSION) def test_port_list(self): ct = ResourceType.from_string("port_list") self.assertEqual(ct, ResourceType.PORT_LIST) def test_report_format(self): ct = ResourceType.from_string("report_format") self.assertEqual(ct, ResourceType.REPORT_FORMAT) def test_report(self): ct = ResourceType.from_string("report") self.assertEqual(ct, ResourceType.REPORT) def test_result(self): ct = ResourceType.from_string("result") self.assertEqual(ct, ResourceType.RESULT) def test_role(self): ct = ResourceType.from_string("role") self.assertEqual(ct, ResourceType.ROLE) def test_scanner(self): ct = ResourceType.from_string("scanner") self.assertEqual(ct, ResourceType.SCANNER) def test_schedule(self): ct = ResourceType.from_string("schedule") self.assertEqual(ct, ResourceType.SCHEDULE) def test_target(self): ct = ResourceType.from_string("target") self.assertEqual(ct, ResourceType.TARGET) def test_task(self): ct = ResourceType.from_string("task") self.assertEqual(ct, ResourceType.TASK) def test_tls_certificate(self): ct = ResourceType.from_string("tls_certificate") self.assertEqual(ct, ResourceType.TLS_CERTIFICATE) def test_user(self): ct = ResourceType.from_string("user") self.assertEqual(ct, ResourceType.USER) def test_allresources(self): with self.assertRaises(InvalidArgument): ResourceType.from_string("allresources") if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/gmpv225/enums/test_scanner_type.py000066400000000000000000000031121466406635600255540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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_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-24.8.0/tests/protocols/gmpv225/enums/test_snmp_algorithms.py000066400000000000000000000030521466406635600262730ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_sort_order.py000066400000000000000000000015461466406635600252550ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_ticket_status.py000066400000000000000000000017461466406635600257630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/enums/test_user_auth_type.py000066400000000000000000000020161466406635600261240ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import InvalidArgument from gvm.protocols.gmp.requests.v225 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-24.8.0/tests/protocols/gmpv225/system/000077500000000000000000000000001466406635600216515ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv225/system/__init__.py000066400000000000000000000001411466406635600237560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/protocols/gmpv225/system/test_aggregates.py000066400000000000000000000004471466406635600254000ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.system.aggregates import GmpGetAggregatesTestMixin from ...gmpv225 import Gmpv225TestCase class Gmpv225GetAggregatesTestCase(GmpGetAggregatesTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/system/test_authentication.py000066400000000000000000000010461466406635600263020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.system.authentication import ( GmpAuthenticateTestMixin, GmpDescribeAuthTestMixin, GmpModifyAuthTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225AuthenticateTestCase(GmpAuthenticateTestMixin, Gmpv225TestCase): pass class Gmpv225ModifyAuthTestCase(GmpModifyAuthTestMixin, Gmpv225TestCase): pass class Gmpv225DescribeAuthCommandTestCase( GmpDescribeAuthTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/system/test_feed.py000066400000000000000000000005661466406635600241740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.system.feed import GmpGetFeedsTestMixin, GmpGetFeedTestMixin from ...gmpv225 import Gmpv225TestCase class Gmpv225GetFeedTestCase(GmpGetFeedTestMixin, Gmpv225TestCase): pass class Gmpv225GetFeedsTestCase(GmpGetFeedsTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/system/test_help.py000066400000000000000000000004061466406635600242120ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.system.help import GmpHelpTestMixin from ...gmpv225 import Gmpv225TestCase class Gmpv225HelpTestCase(GmpHelpTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/system/test_system_reports.py000066400000000000000000000004721466406635600263670ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.system.system_reports import GmpGetSystemReportsTestMixin from ...gmpv225 import Gmpv225TestCase class Gmpv225GetSystemReportsTestCase( GmpGetSystemReportsTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/system/test_trashcan.py000066400000000000000000000007001466406635600250620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.system.trashcan import ( GmpEmptyTrashcanTestMixin, GmpRestoreFromTrashcanTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225EmptyTrashcanTestCase(GmpEmptyTrashcanTestMixin, Gmpv225TestCase): pass class Gmpv225RestoreFromTrashcanTestCase( GmpRestoreFromTrashcanTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/system/test_user_settings.py000066400000000000000000000011161466406635600261570ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.system.user_settings import ( GmpGetUserSettingsTestMixin, GmpGetUserSettingTestMixin, GmpModifyUserSettingTestMixin, ) from ...gmpv225 import Gmpv225TestCase class Gmpv225GetUserSettingTestCase( GmpGetUserSettingTestMixin, Gmpv225TestCase ): pass class Gmpv225GetUserSettingsTestCase( GmpGetUserSettingsTestMixin, Gmpv225TestCase ): pass class Gmpv225ModifyUserSettingTestCase( GmpModifyUserSettingTestMixin, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/system/test_versions.py000066400000000000000000000007021466406635600251310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from ...gmpv224.system.versions import GmpGetVersionTestCase from ...gmpv225 import Gmpv225TestCase from .versions import GmpGetProtocolVersionTestCase class Gmpv225GetVersionCommandTestCase(GmpGetVersionTestCase, Gmpv225TestCase): pass class Gmpv225GmpGetProtocolVersionTestCase( GmpGetProtocolVersionTestCase, Gmpv225TestCase ): pass python-gvm-24.8.0/tests/protocols/gmpv225/system/versions/000077500000000000000000000000001466406635600235215ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/gmpv225/system/versions/__init__.py000066400000000000000000000003251466406635600256320ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from .test_get_protocol_version import GmpGetProtocolVersionTestCase __all__ = ("GmpGetProtocolVersionTestCase",) python-gvm-24.8.0/tests/protocols/gmpv225/system/versions/test_get_protocol_version.py000066400000000000000000000003601466406635600313760ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # class GmpGetProtocolVersionTestCase: def test_protocol_version(self): self.assertEqual(self.gmp.get_protocol_version(), (22, 5)) python-gvm-24.8.0/tests/protocols/gmpv225/test_gmp_types.py000066400000000000000000000021621466406635600237460ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from gvm.protocols.gmp.requests.v225 import HostsOrdering from . import Gmpv225TestCase class GmpWithStatementTestMixin: def test_types(self): with self.gmp: # Test that the values are equal self.assertEqual( self.gmp.types.AlertEvent.TASK_RUN_STATUS_CHANGED.value, "Task run status changed", ) self.assertEqual( self.gmp.types.PermissionSubjectType.USER.value, "user" ) self.assertEqual( self.gmp.types.HostsOrdering.RANDOM.value, "random" ) # Test usability of from_string self.assertEqual( self.gmp.types.HostsOrdering.from_string("reverse"), self.gmp.types.HostsOrdering.REVERSE, ) # Test, that the Enum class types are equal self.assertEqual(self.gmp.types.HostsOrdering, HostsOrdering) class Gmpv225WithStatementTestCase(GmpWithStatementTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/gmpv225/test_with_statement.py000066400000000000000000000010411466406635600247710ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from . import Gmpv225TestCase 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 Gmpv225WithStatementTestCase(GmpWithStatementTestMixin, Gmpv225TestCase): pass python-gvm-24.8.0/tests/protocols/osp/000077500000000000000000000000001466406635600177245ustar00rootroot00000000000000python-gvm-24.8.0/tests/protocols/osp/__init__.py000066400000000000000000000001411466406635600220310ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/protocols/osp/test_osp_delete_scan.py000066400000000000000000000014211466406635600244620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) def test_delete_scan_without_id(self): with self.assertRaises(ValueError): self.osp.delete_scan(None) with self.assertRaises(ValueError): self.osp.delete_scan("") if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/osp/test_osp_get_scanner_details.py000066400000000000000000000010621466406635600262120ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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(b"") if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/osp/test_osp_get_scans.py000066400000000000000000000015021466406635600241620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) def test_get_scans_default_params(self): self.osp.get_scans() self.connection.send.has_been_called_with( b'' ) if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/osp/test_osp_get_version.py000066400000000000000000000010071466406635600245400ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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(b"") if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/osp/test_osp_get_vts.py000066400000000000000000000012661466406635600236760ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) def test_get_vts(self): self.osp.get_vts() self.connection.send.has_been_called_with(b"") if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/osp/test_osp_help.py000066400000000000000000000007541466406635600231540ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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(b"") if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/osp/test_osp_start_scan.py000066400000000000000000000053601466406635600243630ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' b'' b"localhost" b"22,80" b"192.168.10.1" b"443" b"" b'' b"username" b"pass" b"" b"" b'' b'value' b'' b"" ) 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( b'' b"" ) if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/osp/test_osp_stop_scan.py000066400000000000000000000014671466406635600242170ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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( b'' ) 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-24.8.0/tests/protocols/test_latest.py000066400000000000000000000007331466406635600220330ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # # 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(), (22, 5)) def test_osp_version(self): self.assertEqual(Osp.get_protocol_version(), (1, 2)) if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/protocols/test_next.py000066400000000000000000000007311466406635600215130ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # # 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(), (22, 5)) def test_osp_version(self): self.assertEqual(Osp.get_protocol_version(), (1, 2)) if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/test_enum.py000066400000000000000000000042211466406635600174530ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later import unittest from gvm._enum import Enum from gvm.errors import InvalidArgument class SomeEnum(Enum): FOO = "foo" BAR = "bar" LOREM = "ipsum" class OtherEnum(Enum): LOREM = "ipsum" class SomeClass: def __str__(self) -> str: return "foo" class EnumTestCase(unittest.TestCase): def test_enum(self) -> None: enum = SomeEnum("FOO") self.assertEqual(enum, SomeEnum.FOO) enum = SomeEnum("BAR") self.assertEqual(enum, SomeEnum.BAR) enum = SomeEnum("foo") self.assertEqual(enum, SomeEnum.FOO) enum = SomeEnum("bar") self.assertEqual(enum, SomeEnum.BAR) enum = SomeEnum(SomeClass()) self.assertEqual(enum, SomeEnum.FOO) enum = SomeEnum(SomeEnum.BAR) self.assertEqual(enum, SomeEnum.BAR) enum = SomeEnum(SomeEnum.LOREM) self.assertEqual(enum, SomeEnum.LOREM) enum = SomeEnum("ipsum") self.assertEqual(enum, SomeEnum.LOREM) enum = SomeEnum(OtherEnum.LOREM) self.assertEqual(enum, SomeEnum.LOREM) def test_invalid(self) -> None: with self.assertRaisesRegex( InvalidArgument, "^Invalid argument BAZ. Allowed values are FOO,BAR,LOREM.$", ): SomeEnum("BAZ") with self.assertRaisesRegex( ValueError, "^'' is not a valid SomeEnum$", ): SomeEnum("") with self.assertRaisesRegex( ValueError, "^None is not a valid SomeEnum$", ): SomeEnum(None) def test_from_string(self) -> None: enum = SomeEnum.from_string("FOO") self.assertEqual(enum, SomeEnum.FOO) enum = SomeEnum.from_string("BAR") self.assertEqual(enum, SomeEnum.BAR) enum = SomeEnum.from_string("foo") self.assertEqual(enum, SomeEnum.FOO) enum = SomeEnum.from_string("bar") self.assertEqual(enum, SomeEnum.BAR) def test_str(self): self.assertEqual(str(SomeEnum.FOO), "foo") self.assertEqual(str(SomeEnum.BAR), "bar") python-gvm-24.8.0/tests/test_errors.py000066400000000000000000000154371466406635600200360ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import ( GvmError, GvmResponseError, GvmServerError, InvalidArgument, InvalidArgumentType, RequiredArgument, ) 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", arg_type="bar") def test_raise_with_function(self): with self.assertRaisesRegex( InvalidArgumentType, "^In baz the argument foo must be of type bar.$", ): raise InvalidArgumentType("foo", arg_type="bar", function="baz") def test_string_conversion(self): with self.assertRaises(InvalidArgumentType) as cm: raise InvalidArgumentType("foo", arg_type="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", arg_type="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", arg_type="bar") if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/transforms/000077500000000000000000000000001466406635600172755ustar00rootroot00000000000000python-gvm-24.8.0/tests/transforms/__init__.py000066400000000000000000000001411466406635600214020ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/transforms/test_check_command_transform.py000066400000000000000000000033641466406635600255620ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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(b"") 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) 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) 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) 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) self.assertEqual(transform(response), b'') python-gvm-24.8.0/tests/transforms/test_etree_check_command_transform.py000066400000000000000000000022531466406635600267420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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(b"") 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) 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) result = transform(response) self.assertTrue(etree.iselement(result)) self.assertEqual(result.tag, "foo_response") self.assertEqual(result.get("status"), "200") python-gvm-24.8.0/tests/transforms/test_etree_transform.py000066400000000000000000000013431466406635600241060ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from lxml import etree from gvm.transforms import EtreeTransform class EtreeTransformTestCase(unittest.TestCase): def test_transform_response(self): transform = EtreeTransform() result = transform(b"") self.assertTrue(etree.iselement(result)) def test_transform_more_complex_response(self): transform = EtreeTransform() result = transform(b'') self.assertTrue(etree.iselement(result)) self.assertEqual(result.tag, "foo") self.assertEqual(result.get("id"), "bar") self.assertEqual(len(result), 2) python-gvm-24.8.0/tests/utils/000077500000000000000000000000001466406635600162375ustar00rootroot00000000000000python-gvm-24.8.0/tests/utils/__init__.py000066400000000000000000000001411466406635600203440ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/utils/test_add_filter.py000066400000000000000000000013311466406635600217430ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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-24.8.0/tests/utils/test_check_command_status.py000066400000000000000000000041201466406635600240230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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:Error while parsing the command status: Invalid XML " '\''. Error was 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-24.8.0/tests/utils/test_check_port.py000066400000000000000000000021171466406635600217720ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.utils import check_port class TestCheckPort(unittest.TestCase): def test_port_cpe(self): self.assertTrue(check_port("cpe:meh:moo*")) def test_port_cpe_fail(self): self.assertFalse(check_port("cpe:meh haha")) def test_port_general(self): self.assertTrue(check_port("general/tcp")) def test_ports(self): self.assertTrue(check_port("1/tcp")) self.assertTrue(check_port("12/tcp")) self.assertTrue(check_port("123/tcp")) self.assertTrue(check_port("1234/tcp")) self.assertTrue(check_port("12345/tcp")) self.assertTrue(check_port("1/udp")) self.assertTrue(check_port("12/udp")) def test_ports_fail(self): self.assertFalse(check_port("1")) self.assertFalse(check_port("1//udp")) self.assertFalse(check_port("1/12/tcp")) self.assertFalse(check_port("tcp")) self.assertFalse(check_port("general")) self.assertFalse(check_port("lol")) python-gvm-24.8.0/tests/utils/test_deprecation.py000066400000000000000000000012661466406635600221520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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-24.8.0/tests/utils/test_is_list_like.py000066400000000000000000000010551466406635600223230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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-24.8.0/tests/utils/test_to_base64.py000066400000000000000000000006361466406635600214430ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.utils import to_base64 class TestToBase64(unittest.TestCase): def test_to_base64(self): foo64 = to_base64("foo") self.assertEqual("Zm9v", foo64) bar64 = to_base64("bar") self.assertEqual("YmFy", bar64) if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/utils/test_to_bool.py000066400000000000000000000006131466406635600213050ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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-24.8.0/tests/utils/test_to_comma_list.py000066400000000000000000000007171466406635600225060ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2021-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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-24.8.0/tests/xml/000077500000000000000000000000001466406635600156775ustar00rootroot00000000000000python-gvm-24.8.0/tests/xml/__init__.py000066400000000000000000000001411466406635600200040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # python-gvm-24.8.0/tests/xml/test.file000066400000000000000000000000001466406635600175050ustar00rootroot00000000000000python-gvm-24.8.0/tests/xml/test_parse_xml.py000066400000000000000000000015241466406635600213040ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import unittest from gvm.errors import GvmError from gvm.xml import parse_xml class ParseXmlTestCase(unittest.TestCase): def test_missing_closing_tag(self): with self.assertRaises(GvmError): parse_xml("") def test_invalid_tag(self): with self.assertRaises(GvmError): parse_xml("") def test_xml_bomb(self): xml = ( "' '' '' '' "]>" "&c;" ) with self.assertRaises(GvmError): parse_xml(xml) python-gvm-24.8.0/tests/xml/test_pretty_print.py000066400000000000000000000116011466406635600220520ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2019-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import sys import unittest from io import StringIO from unittest.mock import patch from pontos.testing import temp_directory from gvm.errors import InvalidArgumentType from gvm.xml import parse_xml, pretty_print class PrettyPrintTestCase(unittest.TestCase): def test_pretty_print_to_file(self): xml_str = 'and text' elem = parse_xml(xml_str) expected_xml_string = ( "\n" " \n" ' and text\n' " \n" "\n" ) with temp_directory() as temp_dir: test_file = temp_dir / "test.file" with test_file.open("w", encoding="utf-8") as f: pretty_print(elem, file=f) xml_string = test_file.read_text(encoding="utf-8") self.assertEqual(xml_string, expected_xml_string) def test_pretty_print_to_stringio(self): xml_str = 'and text' elem = parse_xml(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 = parse_xml(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 = parse_xml(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 = parse_xml(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 = parse_xml(xml_str) with self.assertRaises(TypeError): pretty_print(elem, file="string") if __name__ == "__main__": unittest.main() python-gvm-24.8.0/tests/xml/test_xml_command.py000066400000000000000000000036021466406635600216070ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2018-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # 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()