pax_global_header00006660000000000000000000000064145760021320014512gustar00rootroot0000000000000052 comment=f873358641128bb05a8ca140c8fbf9ab085b3509 greenbone-feed-sync-24.3.0/000077500000000000000000000000001457600213200154175ustar00rootroot00000000000000greenbone-feed-sync-24.3.0/.docker/000077500000000000000000000000001457600213200167445ustar00rootroot00000000000000greenbone-feed-sync-24.3.0/.docker/Dockerfile000066400000000000000000000023311457600213200207350ustar00rootroot00000000000000FROM debian:stable-slim as builder COPY . /source WORKDIR /source RUN apt-get update && \ apt-get install --no-install-recommends --no-install-suggests -y \ gosu \ python3 \ python-is-python3 \ pipx && \ apt-get remove --purge --auto-remove -y && \ rm -rf /var/lib/apt/lists/* RUN pipx install poetry RUN rm -rf dist && /root/.local/bin/poetry build -f wheel FROM debian:stable-slim ENV PYTHONDONTWRITEBYTECODE 1 ENV PYTHONUNBUFFERED 1 ENV PIP_NO_CACHE_DIR off WORKDIR /greenbone-feed-sync RUN apt-get update && \ apt-get install --no-install-recommends --no-install-suggests -y \ gosu \ rsync \ python3 \ python3-pip && \ apt-get remove --purge --auto-remove -y && \ rm -rf /var/lib/apt/lists/* RUN addgroup --gid 1001 --system gvm && \ adduser --no-create-home --shell /bin/false --disabled-password --uid 1001 --system --group gvm COPY --from=builder /source/dist/* /greenbone-feed-sync/ COPY .docker/entrypoint.sh /usr/local/bin/entrypoint RUN python3 -m pip install --break-system-packages /greenbone-feed-sync/* RUN chown -R gvm:gvm /greenbone-feed-sync && \ chmod 755 /usr/local/bin/entrypoint ENTRYPOINT [ "/usr/local/bin/entrypoint" ] CMD ["/bin/bash"] greenbone-feed-sync-24.3.0/.docker/entrypoint.sh000066400000000000000000000000401457600213200215050ustar00rootroot00000000000000#!/bin/bash exec gosu gvm "$@" greenbone-feed-sync-24.3.0/.dockerignore000066400000000000000000000000671457600213200200760ustar00rootroot00000000000000.git .mypy_cache .ruff_cache .venv .vscode lib htmlcov greenbone-feed-sync-24.3.0/.github/000077500000000000000000000000001457600213200167575ustar00rootroot00000000000000greenbone-feed-sync-24.3.0/.github/CODEOWNERS000066400000000000000000000000501457600213200203450ustar00rootroot00000000000000# default reviewers * @greenbone/devops greenbone-feed-sync-24.3.0/.github/dependabot.yml000066400000000000000000000010471457600213200216110ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: pip directory: "/" schedule: interval: weekly time: "04:00" open-pull-requests-limit: 10 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: - "*" greenbone-feed-sync-24.3.0/.github/workflows/000077500000000000000000000000001457600213200210145ustar00rootroot00000000000000greenbone-feed-sync-24.3.0/.github/workflows/ci-python.yml000066400000000000000000000024041457600213200234510ustar00rootroot00000000000000name: Build and test 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: "greenbone tests" linter: ruff python-version: ${{ matrix.python-version }} test: name: Run all 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 }} codecov: name: Upload coverage to codecov.io runs-on: "ubuntu-latest" steps: - uses: actions/checkout@v4 - name: Install and calculate and upload coverage to codecov.io uses: greenbone/actions/coverage-python@v3 with: python-version: "3.10" token: ${{ secrets.CODECOV_TOKEN }} mypy: name: Check type information uses: greenbone/workflows/.github/workflows/typing-python.yml@main versioning: name: Check versioning uses: greenbone/workflows/.github/workflows/check-version.yml@main greenbone-feed-sync-24.3.0/.github/workflows/codeql-analysis-python.yml000066400000000000000000000022351457600213200261500ustar00rootroot00000000000000# For most projects, this workflow file will not need changing; you simply need # to commit it to your repository. # # You may wish to alter this file to override the set of languages analyzed, # or to provide custom queries or build logic. # # ******** NOTE ******** # We have attempted to detect the languages in your repository. Please check # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # name: "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 }} - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 greenbone-feed-sync-24.3.0/.github/workflows/container.yml000066400000000000000000000030271457600213200235230ustar00rootroot00000000000000name: Container Image Builds on: push: branches: [ main ] tags: ["v*"] workflow_dispatch: jobs: images: name: Build images runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Login to Dockerhub Container Registry if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Setup container meta information id: meta uses: docker/metadata-action@v5 with: images: ${{ github.repository }} labels: | org.opencontainers.image.vendor=Greenbone org.opencontainers.image.documentation=https://greenbone.github.io/docs/ org.opencontainers.image.base.name=debian:stable-slim tags: | # create container tag for git tags type=ref,event=tag # set edge for default branch type=edge - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push Container image uses: docker/build-push-action@v5 with: context: . push: ${{ github.event_name != 'pull_request' }} file: .docker/Dockerfile platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} greenbone-feed-sync-24.3.0/.github/workflows/conventional-commits.yml000066400000000000000000000004421457600213200257070ustar00rootroot00000000000000name: Conventional Commits on: pull_request_target: permissions: pull-requests: write jobs: conventional-commits: name: Conventional Commits runs-on: ubuntu-latest steps: - name: Report Conventional Commits uses: greenbone/actions/conventional-commits@v3 greenbone-feed-sync-24.3.0/.github/workflows/dependency-review.yml000066400000000000000000000003451457600213200251560ustar00rootroot00000000000000name: 'Dependency Review' on: [pull_request] permissions: contents: read jobs: dependency-review: runs-on: ubuntu-latest steps: - name: 'Dependency Review' uses: greenbone/actions/dependency-review@v3 greenbone-feed-sync-24.3.0/.github/workflows/deploy-pypi.yml000066400000000000000000000005121457600213200240100ustar00rootroot00000000000000name: 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/greenbone-feed-sync/ steps: - name: Build and publish to PyPI uses: greenbone/actions/pypi-upload@v3 greenbone-feed-sync-24.3.0/.github/workflows/release-pontos.yml000066400000000000000000000003631457600213200245010ustar00rootroot00000000000000name: 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 greenbone-feed-sync-24.3.0/.github/workflows/sbom-upload.yml000066400000000000000000000004151457600213200237610ustar00rootroot00000000000000name: 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 greenbone-feed-sync-24.3.0/.gitignore000066400000000000000000000024221457600213200174070ustar00rootroot00000000000000# Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ # ruff .ruff_cache/ # vscode settings .vscode # vim settings in virtualenv .vim process.log greenbone-feed-sync-24.3.0/LICENSE000066400000000000000000001045151457600213200164320ustar00rootroot00000000000000 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. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 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: Copyright (C) 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 . greenbone-feed-sync-24.3.0/README.md000066400000000000000000001137071457600213200167070ustar00rootroot00000000000000![Greenbone Logo](https://www.greenbone.net/wp-content/uploads/gb_new-logo_horizontal_rgb_small.png) # greenbone-feed-sync New script for downloading the Greenbone Community Feed - [Installation](#installation) - [Requirements](#requirements) - [Install using pipx](#install-using-pipx) - [Install using pip](#install-using-pip) - [Usage](#usage) - [Usage on Kali Linux](#usage-on-kali-linux) - [Command Completion](#command-completion) - [Settings](#settings) - [verbose](#verbose) - [quiet](#quiet) - [config](#config) - [private-directory](#private-directory) - [compression-level](#compression-level) - [type](#type) - [feed-url](#feed-url) - [destination-prefix](#destination-prefix) - [gvmd-data-destination](#gvmd-data-destination) - [gvmd-data-url](#gvmd-data-url) - [notus-destination](#notus-destination) - [notus-url](#notus-url) - [nasl-destination](#nasl-destination) - [nasl-url](#nasl-url) - [scap-data-destination](#scap-data-destination) - [scap-data-url](#scap-data-url) - [cert-data-destination](#cert-data-destination) - [cert-data-url](#cert-data-url) - [report-formats-destination](#report-formats-destination) - [report-formats-url](#report-formats-url) - [scan-configs-destination](#scan-configs-destination) - [scan-configs-url](#scan-configs-url) - [port-lists-destination](#port-lists-destination) - [port-lists-url](#port-lists-url) - [gvmd-lock-file](#gvmd-lock-file) - [openvas-lock-file](#openvas-lock-file) - [fail-fast](#fail-fast) - [no-wait](#no-wait) - [wait-interval](#wait-interval) - [rsync-timeout](#rsync-timeout) - [group](#group) - [user](#user) - [greenbone-enterprise-feed-key](#greenbone-enterprise-feed-key) - [Config](#config-1) - [Development](#development) - [Maintainer](#maintainer) - [Contributing](#contributing) - [License](#license) ## Installation ### Requirements Python 3.9 and later is supported. `greenbone-feed-sync` requires the `rsync` tool being installed and available within the `PATH`. On Debian based Distributions like Ubuntu and Kali `rsync` can be installed via sudo apt install rsync ### Install using pipx You can install the latest release of **greenbone-feed-sync** from the Python Package Index (pypi) using [pipx] python3 -m pipx install greenbone-feed-sync On Debian based Distributions like Ubuntu and Kali `pipx` itself can be installed via sudo apt install pipx ### Install using pip **NOTE:** The `pip install` command does no longer work out-of-the-box in newer distributions like Ubuntu 23.04 or Debian 12 because of [PEP 668](https://peps.python.org/pep-0668). Please use the [installation via pipx](#install-using-pipx) instead. You can install the latest release of **greenbone-feed-sync** from the Python Package Index ([pypi]) using [pip] python3 -m pip install greenbone-feed-sync ## Usage Most of the time you should just run the script without any arguments to download the new data for all necessary feed types **NOTE:** See details about [usage on Kali Linux](#usage-on-kali-linux) sudo greenbone-feed-sync To get verbose progress output during the data download you might increase the verbosity sudo greenbone-feed-sync -vvv If the script is run in a cron job the output can be turned off via sudo greenbone-feed-sync --quiet To download only a specific feed content the `--type` argument can be used sudo greenbone-feed-sync --type nvt Run `--help` to get information about all possible types and additional argument options greenbone-feed-sync --help ## Usage on Kali Linux When running `greenbone-feed-sync` as root user, for example via sudo, the actual user and group of the process are changed to the `gvm` user and group via [seteuid](https://docs.python.org/3/library/os.html#os.seteuid). This is done to ensure that [`gvmd`](https://github.com/greenbone/gvmd) and [`openvas-scanner`](https://github.com/greenbone/openvas-scanner) can read the downloaded file contents. When using the Greenbone Community Edition installed via packages on Kali Linux a different user and group are used. They are both named `_gvm` instead. Therefore the [group](#group) and [user](#user) settings need to be adjusted. This can be done by using a [config file](#config-1). sudo mkdir /etc/gvm sudo chmod +r /etc/gvm cat <> ~/.bashrc greenbone-feed-sync --print-completion bash > ~/.greenbone-feed-sync-complete.bash ``` Alternatively, you can use the result of the completion command directly with the eval function of your bash shell: ```bash eval "$(greenbone-feed-sync --print-completion bash)" ``` Setup for zsh: ```zsh echo 'fpath=("$HOME/.zsh.d" $fpath)' >> ~/.zsh mkdir -p ~/.zsh.d/ greenbone-feed-sync --print-completion zsh > ~/.zsh.d/_greenbone_feed_sync ``` ## Settings The `greenbone-feed-sync` script is adjustable for all kind of purposes and very flexible which content gets downloaded. Most likely you will never need to adjust the settings because the defaults will suffice. Changing the settings is only required for experts and testing purposes. ### verbose | Name | Value | | -------------------- | -------------------------------------------- | | CLI Argument | `--verbose, -v` | | Config Variable | verbose | | Environment Variable | `GREENBONE_FEED_SYNC_VERBOSE` | | Default Value | 2 | | Description | Log verbosity. `-vvv` for maximum verbosity. | ### quiet | Name | Value | | -------------------- | ---------------------------------------------------------------------------------------- | | CLI Argument | `--quiet` | | Config Variable | | | Environment Variable | | | Default Value | | | Description | Disable all log output. Same as setting `verbose` or `GREENBONE_FEED_SYNC_VERBOSE` to 0 | ### config | Name | Value | | -------------------- | ---------------------------------------------------------------------------- | | CLI Argument | `--config, -c` | | Config Variable | | | Environment Variable | | | Default Value | `~/.config/greenbone-feed-sync.toml` and `/etc/gvm/greenbone-feed-sync.toml` | | Description | TOML config file to load settings from. | ### private-directory | Name | Value | | -------------------- | ------------------------------------------------------------------------------------ | | CLI Argument | `--private-directory` | | Config Variable | private-directory | | Environment Variable | `GREENBONE_FEED_SYNC_PRIVATE_DIRECTORY` | | Default Value | | | Description | (Sub-)Directory to exclude from the sync which will never get deleted automatically. | ### compression-level | Name | Value | | -------------------- | ----------------------------------------------------------------------- | | CLI Argument | `--compression-level` | | Config Variable | compression-level | | Environment Variable | `GREENBONE_FEED_SYNC_COMPRESSION_LEVEL` | | Default Value | 9 | | Description | rsync compression level 0-9. (0 - no compression, 9 - high compression) | ### type | Name | Value | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | CLI Argument | `--type` | | Config Variable | | | Environment Variable | | | Default Value | all | | Description | Specifies which feed data should be downloaded. Possible values are `all`, `nvt`/`nvts`, `gvmd-data`, `scap`, `cert`, `notus`, `nasl`, `report-format`/`report-formats`, `scan-config`/`scan-configs` or `port-list`/`port-lists`. | ### feed-url | Name | Value | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | CLI Argument | | | Config Variable | feed-url | | Environment Variable | `GREENBONE_FEED_SYNC_URL` | | Default Value | `rsync://feed.community.greenbone.net/community` | | Description | URL to download the feed data from. Other URLs will be relative to this URL by default. For example using `rsync://example.com` as feed url the notus url will be `rsync://example.com/vulnerability-feed/22.04/vt-data/notus/`. | ### destination-prefix | Name | Value | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | CLI Argument | | | Config Variable | destination-prefix | | Environment Variable | `GREENBONE_FEED_SYNC_DESTINATION_PREFIX` | | Default Value | `/var/lib/` | | Description | Directory prefix to use for default feed data download destinations. Other download destinations will be relative to this path by default. For example using `/opt/lib` as destination prefix will change the default of the notus destination to `/opt/lib/notus`. | ### gvmd-data-destination | Name | Value | | -------------------- | ------------------------------------------- | | CLI Argument | `--gvmd-data-destination` | | Config Variable | gvmd-data-destination | | Environment Variable | `GREENBONE_FEED_SYNC_GVMD_DATA_DESTINATION` | | Default Value | `/var/lib/gvm/data-objects/gvmd/22.04/` | | Description | Destination of the downloaded gvmd data. | ### gvmd-data-url | Name | Value | | -------------------- | ---------------------------------------------------------------------------------------------- | | CLI Argument | `--gvmd-data-url` | | Config Variable | gvmd-data-url | | Environment Variable | `GREENBONE_FEED_SYNC_GVMD_DATA_URL` | | Default Value | `rsync://feed.community.greenbone.net/community/data-feed/22.04/` | | Description | URL to download the gvmd data from. This includes scan-configs, report-formats and port-lists. | ### notus-destination | Name | Value | | -------------------- | ----------------------------------------- | | CLI Argument | `--notus-destination` | | Config Variable | notus-destination | | Environment Variable | `GREENBONE_FEED_SYNC_NOTUS_DESTINATION` | | Default Value | `/var/lib/notus` | | Description | Destination of the downloaded notus data. | ### notus-url | Name | Value | | -------------------- | ---------------------------------------------------------------------------------------- | | CLI Argument | `--notus-url` | | Config Variable | notus-url | | Environment Variable | `GREENBONE_FEED_SYNC_NOTUS_URL` | | Default Value | `rsync://feed.community.greenbone.net/community/vulnerability-feed/22.04/vt-data/notus/` | | Description | URL to download the notus data from. | ### nasl-destination | Name | Value | | -------------------- | ---------------------------------------- | | CLI Argument | `--nasl-destination` | | Config Variable | nasl-destination | | Environment Variable | `GREENBONE_FEED_SYNC_NASL_DESTINATION` | | Default Value | `/var/lib/openvas/plugins` | | Description | Destination of the downloaded nasl data. | ### nasl-url | Name | Value | | -------------------- | --------------------------------------------------------------------------------------- | | CLI Argument | `--nasl-url` | | Config Variable | nasl-url | | Environment Variable | `GREENBONE_FEED_SYNC_NASL_URL` | | Default Value | `rsync://feed.community.greenbone.net/community/vulnerability-feed/22.04/vt-data/nasl/` | | Description | URL to download the nasl data from. | ### scap-data-destination | Name | Value | | -------------------- | ------------------------------------------- | | CLI Argument | `--scap-data-destination` | | Config Variable | scap-data-destination | | Environment Variable | `GREENBONE_FEED_SYNC_SCAP_DATA_DESTINATION` | | Default Value | `/var/lib/gvm/scap-data` | | Description | Destination of the downloaded SCAP data. | ### scap-data-url | Name | Value | | -------------------- | ----------------------------------------------------------------------------------- | | CLI Argument | `--scap-data-url` | | Config Variable | scap-data-url | | Environment Variable | `GREENBONE_FEED_SYNC_SCAP_DATA_URL` | | Default Value | `rsync://feed.community.greenbone.net/community/vulnerability-feed/22.04/scap-data` | | Description | URL to download the SCAP data from. | ### cert-data-destination | Name | Value | | -------------------- | ------------------------------------------- | | CLI Argument | `--cert-data-destination` | | Config Variable | cert-data-destination | | Environment Variable | `GREENBONE_FEED_SYNC_CERT_DATA_DESTINATION` | | Default Value | `/var/lib/gvm/cert-data` | | Description | Destination of the downloaded CERT data. | ### cert-data-url | Name | Value | | -------------------- | ----------------------------------------------------------------------------------- | | CLI Argument | `--cert-data-url` | | Config Variable | cert-data-url | | Environment Variable | `GREENBONE_FEED_SYNC_CERT_DATA_URL` | | Default Value | `rsync://feed.community.greenbone.net/community/vulnerability-feed/22.04/cert-data` | | Description | URL to download the CERT data from. | ### report-formats-destination | Name | Value | | -------------------- | ----------------------------------------------------- | | CLI Argument | `--report-formats-destination` | | Config Variable | report-formats-destination | | Environment Variable | `GREENBONE_FEED_SYNC_REPORT_FORMATS_DESTINATION` | | Default Value | `/var/lib/gvm/data-objects/gvmd/22.04/report-formats` | | Description | Destination of the downloaded report format data. | ### report-formats-url | Name | Value | | -------------------- | ------------------------------------------------------------------------------- | | CLI Argument | `--report-formats-url` | | Config Variable | report-formats-url | | Environment Variable | `GREENBONE_FEED_SYNC_REPORT_FORMATS_URL` | | Default Value | `rsync://feed.community.greenbone.net/community/data-feed/22.04/report-formats` | | Description | URL to download the report format data from. | ### scan-configs-destination | Name | Value | | -------------------- | --------------------------------------------------- | | CLI Argument | `--scan-configs-destination` | | Config Variable | scan-configs-destination | | Environment Variable | `GREENBONE_FEED_SYNC_SCAN_CONFIGS_DESTINATION` | | Default Value | `/var/lib/gvm/data-objects/gvmd/22.04/scan-configs` | | Description | Destination of the downloaded scan config data. | ### scan-configs-url | Name | Value | | -------------------- | ----------------------------------------------------------------------------- | | CLI Argument | `--scan-configs-url` | | Config Variable | scan-configs-url | | Environment Variable | `GREENBONE_FEED_SYNC_SCAN_CONFIGS_URL` | | Default Value | `rsync://feed.community.greenbone.net/community/data-feed/22.04/scan-configs` | | Description | URL to download the scan config data from. | ### port-lists-destination | Name | Value | | -------------------- | ------------------------------------------------- | | CLI Argument | `--port-lists-destination` | | Config Variable | port-lists-destination | | Environment Variable | `GREENBONE_FEED_SYNC_PORT_LISTS_DESTINATION` | | Default Value | `/var/lib/gvm/data-objects/gvmd/22.04/port-lists` | | Description | Destination of the downloaded port list data. | ### port-lists-url | Name | Value | | -------------------- | --------------------------------------------------------------------------- | | CLI Argument | `--port-lists-url` | | Config Variable | port-lists-url | | Environment Variable | `GREENBONE_FEED_SYNC_PORT_LISTS_URL` | | Default Value | `rsync://feed.community.greenbone.net/community/data-feed/22.04/port-lists` | | Description | URL to download the port list data from. | ### gvmd-lock-file | Name | Value | | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | CLI Argument | `--gvmd-lock-file` | | Config Variable | gvmd-lock-file | | Environment Variable | `GREENBONE_FEED_SYNC_GVMD_LOCK_FILE` | | Default Value | `/var/lib/gvm/feed-update.lock` | | Description | File to use for locking the feed synchronization for data loaded by the gvmd daemon. Used to avoid that more then one process accesses the feed data at the same time. | ### openvas-lock-file | Name | Value | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | CLI Argument | `--openvas-lock-file` | | Config Variable | openvas-lock-file | | Environment Variable | `GREENBONE_FEED_SYNC_OPENVAS_LOCK_FILE` | | Default Value | `/var/lib/openvas/feed-update.lock` | | Description | File to use for locking the feed synchronization for data loaded by the openvas scanner. Used to avoid that more then one process accesses the feed data at the same time. | ### fail-fast | Name | Value | | -------------------- | ----------------------------------------------------------------------------------------------------------- | | CLI Argument | `--fail-fast, --failfast` | | Config Variable | fail-fast | | Environment Variable | `GREENBONE_FEED_SYNC_FAIL_FAST` | | Default Value | false | | Description | Stop after a first error has occurred. Otherwise the script tries to download additional data if specified. | ### no-wait | Name | Value | | -------------------- | ------------------------------------------------- | | CLI Argument | `--no-wait` | | Config Variable | no-wait | | Environment Variable | `GREENBONE_FEED_SYNC_NO_WAIT` | | Default Value | false | | Description | Fail directly if the lock file can't be acquired. | ### wait-interval | Name | Value | | -------------------- | ------------------------------------------------------------------------------------ | | CLI Argument | `--wait-interval` | | Config Variable | wait-interval | | Environment Variable | `GREENBONE_FEED_SYNC_LOCK_WAIT_INTERVAL` | | Default Value | 5 | | Description | Time to wait in seconds after failed lock attempt before re-trying to lock the file. | ### rsync-timeout | Name | Value | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | CLI Argument | `--rsync-timeout` | | Config Variable | rsync-timeout | | Environment Variable | `GREENBONE_FEED_SYNC_RSYNC_TIMEOUT` | | Default Value | | | Description | Maximum I/O timeout in seconds used for rsync. If no data is transferred for the specified time then rsync will exit. By default no timeout is set and the rsync default will be used. | ### group | Name | Value | | -------------------- | ---------------------------------------------------------------------------------------------------------- | | CLI Argument | `--group` | | Config Variable | group | | Environment Variable | `GREENBONE_FEED_SYNC_GROUP` | | Default Value | gvm | | Description | If the greenbone-feed-sync script is run as root, the effective group is changed to this group name or ID. | ### user | Name | Value | | -------------------- | -------------------------------------------------------------------------------------------------------- | | CLI Argument | `--user` | | Config Variable | user | | Environment Variable | `GREENBONE_FEED_SYNC_USER` | | Default Value | gvm | | Description | If the greenbone-feed-sync script is run as root, the effective user is changed to this user name or ID. | ### greenbone-enterprise-feed-key | Name | Value | | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | CLI Argument | `--greenbone-enterprise-feed-key` | | Config Variable | greenbone-enterprise-feed-key | | Environment Variable | `GREENBONE_FEED_SYNC_ENTERPRISE_FEED_KEY` | | Default Value | /etc/gvm/greenbone-enterprise-feed-key | | Description | File to read the Greenbone Enterprise Feed key from. The key gives access to additional vulnerability tests for enterprise software among other advantages. See [Greenbone Enterprise Feed and Greenbone Community Feed in Comparison](https://www.greenbone.net/en/feed-comparison/) for more details. The default URLs are adjusted according to the data in the key. If the key file does not exist it is ignored. | ## Config It is possible to use a config file for loading the settings of the `greenbone-feed-sync` script. The config file uses the [TOML] format. Without explicitly passing a config file, `greenbone-feed-sync` tries to load `~/.config/greenbone-feed-sync.toml` and if that file doesn't exist afterwards `/etc/gvm/greenbone-feed-sync.toml`. Example: ```toml [greenbone-feed-sync] destination-prefix = "/opt/greenbone-feed" lock-file = "/opt/greenbone-feed.lock" no-wait = true ``` ## Development **greenbone-feed-sync** uses [poetry] for its own dependency management and build process. First install poetry via pipx python3 -m pipx install poetry Afterwards run poetry install in the checkout directory of **greenbone-feed-sync** (the directory containing the `pyproject.toml` file) to install all dependencies including the packages only required for development. Afterwards activate the git hooks for auto-formatting and linting via [autohooks]. poetry run autohooks activate Validate the activated git hooks by running poetry run autohooks check ## Maintainer This project is maintained by [Greenbone AG][Greenbone Networks] ## Contributing Your contributions are highly appreciated. Please [create a pull request](https://github.com/greenbone/greeenbon-feed-sync/pulls) on GitHub. Bigger changes need to be discussed with the development team via the [issues section at GitHub](https://github.com/greenbone/greenbone-feed-sync/issues) first. ## License Copyright (C) 2022-2024 [Greenbone AG][Greenbone Networks] Licensed under the [GNU General Public License v3.0 or later](LICENSE). [Greenbone Networks]: https://www.greenbone.net/ [poetry]: https://python-poetry.org/ [pip]: https://pip.pypa.io/ [pipx]: https://pypa.github.io/pipx/ [autohooks]: https://github.com/greenbone/autohooks [TOML]: https://toml.io/ [pypi]: https://pypi.org greenbone-feed-sync-24.3.0/greenbone/000077500000000000000000000000001457600213200173635ustar00rootroot00000000000000greenbone-feed-sync-24.3.0/greenbone/feed/000077500000000000000000000000001457600213200202665ustar00rootroot00000000000000greenbone-feed-sync-24.3.0/greenbone/feed/sync/000077500000000000000000000000001457600213200212425ustar00rootroot00000000000000greenbone-feed-sync-24.3.0/greenbone/feed/sync/__init__.py000066400000000000000000000001411457600213200233470ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # greenbone-feed-sync-24.3.0/greenbone/feed/sync/__version__.py000066400000000000000000000001471457600213200240770ustar00rootroot00000000000000# pylint: disable=invalid-name # THIS IS AN AUTOGENERATED FILE. DO NOT TOUCH! __version__ = "24.3.0" greenbone-feed-sync-24.3.0/greenbone/feed/sync/config.py000066400000000000000000000256621457600213200230740ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import os from dataclasses import dataclass from pathlib import Path from typing import Any, Callable, Iterable, Optional, Protocol, Union from urllib.parse import urlsplit from greenbone.feed.sync.errors import ConfigFileError from greenbone.feed.sync.helper import DEFAULT_FLOCK_WAIT_INTERVAL from greenbone.feed.sync.rsync import ( DEFAULT_RSYNC_COMPRESSION_LEVEL, DEFAULT_RSYNC_URL, ) try: import tomllib except ImportError: import tomli as tomllib # type: ignore[no-redef] def maybe_int(value: Optional[str]) -> Union[int, str, None]: """ Convert string into int if possible """ try: value = int(value) # type: ignore[arg-type,assignment] except ValueError: pass return value DEFAULT_VERSION = "22.04" DEFAULT_NOTUS_URL_PATH = f"/vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/" DEFAULT_NASL_URL_PATH = f"/vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/" DEFAULT_SCAP_DATA_URL_PATH = f"/vulnerability-feed/{DEFAULT_VERSION}/scap-data/" DEFAULT_CERT_DATA_URL_PATH = f"/vulnerability-feed/{DEFAULT_VERSION}/cert-data/" DEFAULT_GVMD_DATA_URL_PATH = f"/data-feed/{DEFAULT_VERSION}/" DEFAULT_REPORT_FORMATS_URL_PATH = ( f"/data-feed/{DEFAULT_VERSION}/report-formats/" ) DEFAULT_SCAN_CONFIGS_URL_PATH = f"/data-feed/{DEFAULT_VERSION}/scan-configs/" DEFAULT_PORT_LISTS_URL_PATH = f"/data-feed/{DEFAULT_VERSION}/port-lists/" DEFAULT_DESTINATION_PREFIX = "/var/lib/" DEFAULT_NASL_PATH = "openvas/plugins" DEFAULT_NOTUS_PATH = "notus" DEFAULT_SCAP_DATA_PATH = "gvm/scap-data" DEFAULT_CERT_DATA_PATH = "gvm/cert-data" DEFAULT_GVMD_DATA_PATH = f"gvm/data-objects/gvmd/{DEFAULT_VERSION}/" DEFAULT_REPORT_FORMATS_PATH = ( f"gvm/data-objects/gvmd/{DEFAULT_VERSION}/report-formats" ) DEFAULT_SCAN_CONFIGS_PATH = ( f"gvm/data-objects/gvmd/{DEFAULT_VERSION}/scan-configs" ) DEFAULT_PORT_LISTS_PATH = f"gvm/data-objects/gvmd/{DEFAULT_VERSION}/port-lists" DEFAULT_GVMD_LOCK_FILE_PATH = "gvm/feed-update.lock" DEFAULT_OPENVAS_LOCK_FILE_PATH = "openvas/feed-update.lock" DEFAULT_CONFIG_FILE = "/etc/gvm/greenbone-feed-sync.toml" DEFAULT_USER_CONFIG_FILE = "~/.config/greenbone-feed-sync.toml" DEFAULT_ENTERPRISE_KEY_PATH = "/etc/gvm/greenbone-enterprise-feed-key" DEFAULT_GROUP = "gvm" DEFAULT_USER = "gvm" DEFAULT_VERBOSITY = 2 @dataclass class Setting: config_key: str environment_key: str default_value: Union[str, int, bool, None] value_type: Callable def resolve(self, values: dict[str, Any]) -> Any: value: Any if self.environment_key in os.environ: value = os.environ.get(self.environment_key) elif self.config_key in values: value = values.get(self.config_key) else: value = self.default_value return None if value is None else self.value_type(value) @dataclass class DependentSetting: config_key: str environment_key: str default_value: Callable value_type: Callable def resolve(self, values: dict[str, Any]) -> Any: if self.environment_key in os.environ: value = os.environ.get(self.environment_key) elif self.config_key in values: value = values.get(self.config_key) else: value = self.default_value(values) return None if value is None else self.value_type(value) @dataclass class EnterpriseSettings: user: Optional[str] host: Optional[str] key: Path @classmethod def from_key(cls, enterprise_key: Path) -> "EnterpriseSettings": with enterprise_key.open("r", encoding="utf8", errors="ignore") as f: line = f.readline() url = urlsplit(line) if not url.scheme: # ensure that url gets splitted correctly if line doesn't contain # an url scheme (which is the default) url = urlsplit(f"//{line}") return EnterpriseSettings(url.username, url.hostname, enterprise_key) def feed_url(self) -> str: return f"ssh://{self.user}@{self.host}/enterprise" _SETTINGS = ( Setting( "destination-prefix", "GREENBONE_FEED_SYNC_DESTINATION_PREFIX", DEFAULT_DESTINATION_PREFIX, Path, ), Setting("feed-url", "GREENBONE_FEED_SYNC_URL", DEFAULT_RSYNC_URL, str), Setting( "wait-interval", "GREENBONE_FEED_SYNC_LOCK_WAIT_INTERVAL", DEFAULT_FLOCK_WAIT_INTERVAL, int, ), Setting("no-wait", "GREENBONE_FEED_SYNC_NO_WAIT", False, bool), Setting( "compression-level", "GREENBONE_FEED_SYNC_COMPRESSION_LEVEL", DEFAULT_RSYNC_COMPRESSION_LEVEL, int, ), Setting( "private-directory", "GREENBONE_FEED_SYNC_PRIVATE_DIRECTORY", None, Path ), Setting("verbose", "GREENBONE_FEED_SYNC_VERBOSE", None, int), Setting("fail-fast", "GREENBONE_FEED_SYNC_FAIL_FAST", False, bool), Setting("rsync-timeout", "GREENBONE_FEED_SYNC_RSYNC_TIMEOUT", None, int), Setting("group", "GREENBONE_FEED_SYNC_GROUP", DEFAULT_GROUP, maybe_int), Setting("user", "GREENBONE_FEED_SYNC_USER", DEFAULT_USER, maybe_int), Setting( "greenbone-enterprise-feed-key", "GREENBONE_FEED_SYNC_ENTERPRISE_FEED_KEY", DEFAULT_ENTERPRISE_KEY_PATH, Path, ), ) # pylint: disable=line-too-long _DEPENDENT_SETTINGS = ( DependentSetting( "gvmd-data-destination", "GREENBONE_FEED_SYNC_GVMD_DATA_DESTINATION", lambda values: f"{values['destination-prefix']}/{DEFAULT_GVMD_DATA_PATH}", # noqa: E501 Path, ), DependentSetting( "gvmd-data-url", "GREENBONE_FEED_SYNC_GVMD_DATA_URL", lambda values: f"{values['feed-url']}{DEFAULT_GVMD_DATA_URL_PATH}", str, ), DependentSetting( "notus-destination", "GREENBONE_FEED_SYNC_NOTUS_DESTINATION", lambda values: f"{values['destination-prefix']}/{DEFAULT_NOTUS_PATH}", Path, ), DependentSetting( "notus-url", "GREENBONE_FEED_SYNC_NOTUS_URL", lambda values: f"{values['feed-url']}{DEFAULT_NOTUS_URL_PATH}", str, ), DependentSetting( "nasl-destination", "GREENBONE_FEED_SYNC_NASL_DESTINATION", lambda values: f"{values['destination-prefix']}/{DEFAULT_NASL_PATH}", Path, ), DependentSetting( "nasl-url", "GREENBONE_FEED_SYNC_NASL_URL", lambda values: f"{values['feed-url']}{DEFAULT_NASL_URL_PATH}", str, ), DependentSetting( "scap-data-destination", "GREENBONE_FEED_SYNC_SCAP_DATA_DESTINATION", lambda values: f"{values['destination-prefix']}/{DEFAULT_SCAP_DATA_PATH}", # noqa: E501 Path, ), DependentSetting( "scap-data-url", "GREENBONE_FEED_SYNC_SCAP_DATA_URL", lambda values: f"{values['feed-url']}{DEFAULT_SCAP_DATA_URL_PATH}", str, ), DependentSetting( "cert-data-destination", "GREENBONE_FEED_SYNC_CERT_DATA_DESTINATION", lambda values: f"{values['destination-prefix']}/{DEFAULT_CERT_DATA_PATH}", # noqa: E501 Path, ), DependentSetting( "cert-data-url", "GREENBONE_FEED_SYNC_CERT_DATA_URL", lambda values: f"{values['feed-url']}{DEFAULT_CERT_DATA_URL_PATH}", str, ), DependentSetting( "report-formats-destination", "GREENBONE_FEED_SYNC_REPORT_FORMATS_DESTINATION", lambda values: f"{values['destination-prefix']}/{DEFAULT_REPORT_FORMATS_PATH}", # noqa: E501 Path, ), DependentSetting( "report-formats-url", "GREENBONE_FEED_SYNC_REPORT_FORMATS_URL", lambda values: f"{values['feed-url']}{DEFAULT_REPORT_FORMATS_URL_PATH}", # noqa: E501 str, ), DependentSetting( "scan-configs-destination", "GREENBONE_FEED_SYNC_SCAN_CONFIGS_DESTINATION", lambda values: f"{values['destination-prefix']}/{DEFAULT_SCAN_CONFIGS_PATH}", # noqa: E501 Path, ), DependentSetting( "scan-configs-url", "GREENBONE_FEED_SYNC_SCAN_CONFIGS_URL", lambda values: f"{values['feed-url']}{DEFAULT_SCAN_CONFIGS_URL_PATH}", str, ), DependentSetting( "port-lists-destination", "GREENBONE_FEED_SYNC_PORT_LISTS_DESTINATION", lambda values: f"{values['destination-prefix']}/{DEFAULT_PORT_LISTS_PATH}", # noqa: E501 Path, ), DependentSetting( "port-lists-url", "GREENBONE_FEED_SYNC_PORT_LISTS_URL", lambda values: f"{values['feed-url']}{DEFAULT_PORT_LISTS_URL_PATH}", str, ), DependentSetting( "gvmd-lock-file", "GREENBONE_FEED_SYNC_GVMD_LOCK_FILE", lambda values: f"{values['destination-prefix']}/{DEFAULT_GVMD_LOCK_FILE_PATH}", # noqa: E501 Path, ), DependentSetting( "openvas-lock-file", "GREENBONE_FEED_SYNC_OPENVAS_LOCK_FILE", lambda values: f"{values['destination-prefix']}/{DEFAULT_OPENVAS_LOCK_FILE_PATH}", # noqa: E501 Path, ), ) class ConfigDict(Protocol): def items(self) -> Iterable[tuple[str, Any]]: ... def __getitem__(self, key: str) -> Any: ... class Config: """ A class to load configuration values from the environment, config file and defaults. """ def __init__(self) -> None: self._config: dict[str, Any] = {} def load_from_config_file(self, config_file: Path) -> None: try: content = config_file.read_text(encoding="utf-8") config_data = tomllib.loads(content) self._config = config_data.get("greenbone-feed-sync", {}) except IOError as e: raise ConfigFileError( f"Can't load config file {config_file.absolute()}. " f"Error was {e}." ) from e except tomllib.TOMLDecodeError as e: raise ConfigFileError( f"Can't load config file. {config_file.absolute()} is not " "a valid TOML file." ) from e def apply_settings(self) -> None: for setting in _SETTINGS: self._config[setting.config_key] = setting.resolve(self._config) def apply_dependent_settings(self) -> None: for setting in _DEPENDENT_SETTINGS: self._config[setting.config_key] = setting.resolve(self._config) @classmethod def load(cls, config_file: Optional[Path] = None) -> "Config": """ Load config values from config_file and apply all settings """ config = cls() if config_file: config.load_from_config_file(config_file) config.apply_settings() config.apply_dependent_settings() return config def items(self) -> Iterable[tuple[str, Any]]: return self._config.items() def __getitem__(self, key: str) -> Any: return self._config[key] def __setitem__(self, key: str, value: Any) -> None: self._config[key] = value def __len__(self) -> int: return len(self._config) greenbone-feed-sync-24.3.0/greenbone/feed/sync/errors.py000066400000000000000000000040211457600213200231250ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from typing import Iterable, Optional class GreenboneFeedSyncError(Exception): """ Base exception class """ class ConfigFileError(GreenboneFeedSyncError): """ Error while processing a config file """ class ExecProcessError(GreenboneFeedSyncError): """ Error while executing a process """ def __init__( self, returncode: int, cmd: Iterable[str], *, stdout: Optional[bytes] = None, stderr: Optional[bytes] = None, ) -> None: self.returncode = returncode self.cmd = cmd self.stout = ( None if not stdout else stdout.decode("utf8", errors="ignore") ) self.stderr = ( None if not stderr else stderr.decode("utf8", errors="ignore") ) def __str__(self): cmd = " ".join(self.cmd) return f"'{cmd}' returned non-zero exit status {self.returncode}." class RsyncError(ExecProcessError): """ Error while running rsync """ def __init__( self, returncode: int, args: Iterable[str], stderr: Optional[bytes] = None, ) -> None: super().__init__(returncode, cmd=["rsync"] + list(args), stderr=stderr) class FileLockingError(GreenboneFeedSyncError): """ An error during locking a file """ greenbone-feed-sync-24.3.0/greenbone/feed/sync/helper.py000066400000000000000000000121351457600213200230750ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import asyncio import errno import fcntl import os import shutil from contextlib import asynccontextmanager from pathlib import Path from types import TracebackType from typing import AsyncGenerator, Optional, Type, Union from rich.console import Console from rich.live import Live from rich.spinner import Spinner as RichSpinner from greenbone.feed.sync.errors import FileLockingError, GreenboneFeedSyncError DEFAULT_FLOCK_WAIT_INTERVAL = 5 # in seconds def is_root() -> bool: """ Checks if the current user is root """ return os.geteuid() == 0 @asynccontextmanager async def flock_wait( path: Union[str, Path], *, console: Optional[Console] = None, wait_interval: Optional[Union[int, float]] = DEFAULT_FLOCK_WAIT_INTERVAL, ) -> AsyncGenerator[None, None]: """ Try to lock a file and wait if it is already locked Arguments: path: File to lock console: A console to print messages to or None to keep the function quiet. wait_interval: Time to wait in seconds after failed lock attempt before re-trying to lock the file. Set to None to raise a FileLockingError instead of re-trying to acquire the lock. Default is 5 seconds. """ # ensure path is a Path path = Path(path) # ensure parent directories exist try: path.parent.mkdir(parents=True, exist_ok=True, mode=0o770) except OSError as e: raise FileLockingError( f"Could not create parent directories for {path}" ) from e try: with path.open("w", encoding="utf8") as fd0: has_lock = False while not has_lock: try: if console: console.print( f"Trying to acquire lock on {path.absolute()}" ) fcntl.flock(fd0, fcntl.LOCK_EX | fcntl.LOCK_NB) if console: console.print(f"Acquired lock on {path.absolute()}") has_lock = True path.chmod(mode=0o660) except OSError as e: if e.errno in (errno.EAGAIN, errno.EACCES): if wait_interval is None: raise FileLockingError( f"{path.absolute()} is locked. Another process " "related to the feed update may already running." ) from None if console: console.print( f"{path.absolute()} is locked by another process. " f"Waiting {wait_interval} seconds before next try." ) await asyncio.sleep(wait_interval) else: raise try: yield finally: try: # free the lock if console: console.print(f"Releasing lock on {path.absolute()}") fcntl.flock(fd0, fcntl.LOCK_UN) except OSError: pass except PermissionError as e: raise FileLockingError( "Permission error while trying to open the lock file " f"{path.absolute()}" ) from e class Spinner: def __init__(self, console: Console, status: str) -> None: self._spinner = RichSpinner( "dots", text=status, style="status.spinner", speed=1.0 ) self._live = Live( self._spinner, console=console, refresh_per_second=12.5, transient=False, ) def __enter__(self) -> "Spinner": self._live.start() return self def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType], ) -> None: self._live.stop() def change_user_and_group( user: Union[str, int], group: Union[str, int] ) -> None: """ Change effective user or group of the current running process Args: user: User name or ID group: Group name or ID """ if isinstance(user, str): user_id = shutil._get_uid( # type: ignore[attr-defined] # pylint: disable=protected-access # noqa: E501 user ) if user_id is None: raise GreenboneFeedSyncError( f"Can't run as user '{user}'. User '{user}' is unknown." ) user = user_id if isinstance(group, str): group_id = shutil._get_gid(group) # type: ignore[attr-defined] # pylint: disable=protected-access # noqa: E501 if group_id is None: raise GreenboneFeedSyncError( f"Can't run as group '{group}'. Group '{group}' is unknown." ) group = group_id os.setegid(group) # type: ignore[arg-type] os.seteuid(user) # type: ignore[arg-type] greenbone-feed-sync-24.3.0/greenbone/feed/sync/main.py000066400000000000000000000137251457600213200225500ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import asyncio import subprocess import sys from dataclasses import dataclass from typing import Iterable, NoReturn from rich.console import Console from greenbone.feed.sync.config import DEFAULT_VERBOSITY from greenbone.feed.sync.errors import GreenboneFeedSyncError, RsyncError from greenbone.feed.sync.helper import ( Spinner, change_user_and_group, flock_wait, is_root, ) from greenbone.feed.sync.parser import CliParser from greenbone.feed.sync.rsync import Rsync __all__ = ("main",) @dataclass class Sync: """ Class to store sync information """ name: str types: Iterable[str] url: str destination: str @dataclass class SyncList: """ Class to store a list of sync information """ lock_file: str syncs: Iterable[Sync] def filter_syncs(lock_file: str, feed_type: str, *syncs: Sync) -> SyncList: """ Create a list of syncs which only match to the feed type """ return SyncList( lock_file=lock_file, syncs=[sync for sync in syncs if feed_type in sync.types], ) def do_selftest() -> None: """ Check for rsync command. """ try: subprocess.run( ["rsync", "--help"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True, ) except (PermissionError, FileNotFoundError, subprocess.CalledProcessError): raise GreenboneFeedSyncError( "The rsync binary could not be found." ) from None async def feed_sync(console: Console, error_console: Console) -> int: """ Sync the feeds """ parser = CliParser() args = parser.parse_arguments() do_selftest() if args.selftest: return 0 if args.quiet: verbose = 0 else: verbose = DEFAULT_VERBOSITY if args.verbose is None else args.verbose if is_root(): if verbose >= 1: console.print( f"Running as root. Switching to user '{args.user}' and " f"group '{args.group}'." ) change_user_and_group(args.user, args.group) rsync = Rsync( private_subdir=args.private_directory, verbose=verbose >= 3, compression_level=args.compression_level, ssh_key=args.greenbone_enterprise_feed_key, ) openvas_syncs = filter_syncs( args.openvas_lock_file, args.type, Sync( name="Notus files", types=("notus", "nvt", "all"), url=args.notus_url, destination=args.notus_destination, ), Sync( name="NASL files", types=("nasl", "nvt", "all"), url=args.nasl_url, destination=args.nasl_destination, ), ) gvmd_syncs = filter_syncs( args.gvmd_lock_file, args.type, Sync( name="SCAP data", types=("scap", "all"), url=args.scap_data_url, destination=args.scap_data_destination, ), Sync( name="CERT-Bund data", types=("cert", "all"), url=args.cert_data_url, destination=args.cert_data_destination, ), Sync( name="gvmd data", types=("gvmd-data", "all"), url=args.gvmd_data_url, destination=args.gvmd_data_destination, ), Sync( name="report formats", types=("report-format"), url=args.report_formats_url, destination=args.report_formats_destination, ), Sync( name="scan configs", types=("scan-config"), url=args.scan_configs_url, destination=args.scan_configs_destination, ), Sync( name="port lists", types=("port-list"), url=args.port_lists_url, destination=args.port_lists_destination, ), ) has_error = False wait_interval = None if args.no_wait else args.wait_interval for sync_list in (openvas_syncs, gvmd_syncs): if not sync_list.syncs: continue async with flock_wait( sync_list.lock_file, console=console if verbose else None, wait_interval=wait_interval, ): for sync in sync_list.syncs: try: rsync_coro = rsync.sync( url=sync.url, destination=sync.destination ) if verbose >= 3: console.print( f"Downloading {sync.name} from {sync.url} to " f"{sync.destination}" ) await rsync_coro # add newline after rsync console.print() elif verbose >= 1: with Spinner( console, f"Downloading {sync.name} from {sync.url} to " f"{sync.destination}", ): await rsync_coro else: await rsync_coro except RsyncError as e: has_error = True error_console.print(e.stderr) if args.fail_fast: return 1 if verbose >= 2: # add newline for grouping lock console.print() return 1 if has_error else 0 def main() -> NoReturn: """ Main CLI function """ console = Console() error_console = Console(stderr=True) try: sys.exit(asyncio.run(feed_sync(console, error_console))) except GreenboneFeedSyncError as e: error_console.print(f"[red]❌[/red]Error: {e}") sys.exit(1) except KeyboardInterrupt: sys.exit(1) if __name__ == "__main__": main() greenbone-feed-sync-24.3.0/greenbone/feed/sync/parser.py000066400000000000000000000303461457600213200231160ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # from argparse import ArgumentParser, Namespace from pathlib import Path from typing import Any, Optional, Sequence import shtab from greenbone.feed.sync.__version__ import __version__ from greenbone.feed.sync.config import ( DEFAULT_CONFIG_FILE, DEFAULT_USER_CONFIG_FILE, Config, ConfigDict, EnterpriseSettings, maybe_int, ) from greenbone.feed.sync.errors import ConfigFileError def _to_defaults(values: ConfigDict) -> dict[str, Any]: defaults = {} for key, value in values.items(): defaults[key.replace("-", "_")] = value return defaults def feed_type(value: str) -> str: """ Converts to a specific feed type """ value = value.replace("_", "-").lower() if value in ("nvts", "report-formats", "port-lists", "scan-configs"): return value[:-1] return value class CliParser: """ An ArgumentParser for the feed sync CLI """ def __init__(self) -> None: parser = ArgumentParser(add_help=False) shtab.add_argument_to(parser) parser.add_argument( "--version", help="Print version then exit.", action="version", version=f"%(prog)s {__version__}", ) parser.add_argument( "-h", "--help", help="Show this help message and exit.", action="store_true", ) parser.add_argument( "--selftest", help="Perform self-test and set exit code", action="store_true", ) output_group = parser.add_mutually_exclusive_group() output_group.add_argument( "--verbose", "-v", action="count", help="Set log verbosity. `-vvv` for maximum verbosity. " "(Default: %(default)s)", ) output_group.add_argument( "--quiet", action="store_true", help="Disable all log output." ) parser.add_argument( "-c", "--config", help="Configuration file path. If not set %(prog)s " f"tries to load {DEFAULT_USER_CONFIG_FILE} or " f"{DEFAULT_CONFIG_FILE}.", ) parser.add_argument( "--private-directory", help="(Sub-)Directory to exclude from the sync which will never " "get deleted automatically.", type=Path, ) parser.add_argument( "--compression-level", type=int, choices=range(0, 10), help="Rsync compression level (0-9). (Default: %(default)s)", ) parser.add_argument( "--type", choices=[ "all", "nvt", "gvmd-data", "scap", "cert", "notus", "nasl", "report-format", "scan-config", "port-list", ], default="all", type=feed_type, help="Select which feed should be synced. (Default: %(default)s)", ) parser.add_argument( "--gvmd-data-destination", type=Path, help="Destination of the downloaded gvmd data. " "(Default: %(default)s)", ) parser.add_argument( "--gvmd-data-url", help="URL to download the gvmd data from. " "(Default: %(default)s)", ) nvts_destination_group = parser.add_argument_group() nvts_destination_group.add_argument( "--notus-destination", type=Path, help="Destination of the downloaded notus data. " "(Default: %(default)s)", ) nvts_url_group = parser.add_argument_group() nvts_url_group.add_argument( "--notus-url", help="URL to download the notus data from. " "(Default: %(default)s)", ) nvts_destination_group.add_argument( "--nasl-destination", type=Path, help="Destination of the downloaded nasl data. " "(Default: %(default)s)", ) nvts_url_group.add_argument( "--nasl-url", help="URL to download the nasl data from. " "(Default: %(default)s)", ) secinfo_destination_group = parser.add_argument_group() secinfo_destination_group.add_argument( "--scap-data-destination", type=Path, help="Destination of the downloaded SCAP data. " "(Default: %(default)s)", ) secinfo_url_group = parser.add_argument_group() secinfo_url_group.add_argument( "--scap-data-url", help="URL to download the SCAP data from. " "(Default: %(default)s)", ) secinfo_destination_group.add_argument( "--cert-data-destination", type=Path, help="Destination of the downloaded CERT data. " "(Default: %(default)s)", ) secinfo_url_group.add_argument( "--cert-data-url", help="URL to download the CERT data from. " "(Default: %(default)s)", ) data_objects_destination_group = parser.add_argument_group() data_objects_destination_group.add_argument( "--report-formats-destination", type=Path, help="Destination of the downloaded report format data " "(Default: %(default)s)", ) data_objects_url_group = parser.add_argument_group() data_objects_url_group.add_argument( "--report-formats-url", help="URL to download the report format data from. " "(Default: %(default)s)", ) data_objects_destination_group.add_argument( "--scan-configs-destination", type=Path, help="Destination of the downloaded scan config data. " "(Default: %(default)s)", ) data_objects_url_group.add_argument( "--scan-configs-url", help="URL to download the scan config data from. " "(Default: %(default)s)", ) data_objects_destination_group.add_argument( "--port-lists-destination", type=Path, help="Destination of the downloaded port list data. " "(Default: %(default)s)", ) data_objects_url_group.add_argument( "--port-lists-url", help="URL to download the port list data from. " "(Default: %(default)s)", ) lock_file_group = parser.add_argument_group() lock_file_group.add_argument( "--gvmd-lock-file", type=Path, help="File to use for locking the feed synchronization for data " "loaded by the gvmd daemon. Used to avoid that more then one " "process accesses the feed data at the same time. " "(Default: %(default)s)", ) lock_file_group.add_argument( "--openvas-lock-file", type=Path, help="File to use for locking the feed synchronization for data " "loaded by the openvas scanner. Used to avoid that more then one " "process accesses the feed data at the same time. " "(Default: %(default)s)", ) parser.add_argument( "--fail-fast", "--failfast", action="store_true", help="Stop after a first error has occurred. Otherwise the script " "tries to download additional data if specified.", ) wait_group = parser.add_mutually_exclusive_group() wait_group.add_argument( "--no-wait", action="store_true", help="Fail directly if the lock file can't be acquired.", ) wait_group.add_argument( "--wait-interval", type=int, help="Time to wait in seconds after failed lock attempt before" "re-trying to lock the file. (Default: %(default)s seconds)", ) parser.add_argument( "--rsync-timeout", type=int, help="Maximum I/O timeout in seconds used for rsync. If no data is " "transferred for the specified time then rsync will exit. By " "default no timeout is set and the rsync default will be used.", ) permissions_group = parser.add_argument_group() permissions_group.add_argument( "--user", type=maybe_int, help="If started as root, use this user name or ID to run the " "script. (Default: %(default)s)", ) permissions_group.add_argument( "--group", type=maybe_int, help="If started as root, use this group name or ID to run the " "script. (Default: %(default)s)", ) parser.add_argument( "--greenbone-enterprise-feed-key", type=Path, help="File to read the Greenbone Enterprise Feed key from. " "The key gives access to additional vulnerability tests for " "enterprise software among other advantages. See " "https://www.greenbone.net/en/feed-comparison/ for more details." "The default URLs are adjusted according to the data in the key." "If the key file does not exist it is ignored. " "(Default: %(default)s)", ) self.parser = parser def _determine_enterprise_settings( self, enterprise_key: Path ) -> Optional[EnterpriseSettings]: if not enterprise_key or not enterprise_key.exists(): return None return EnterpriseSettings.from_key(enterprise_key) def _load_config(self, config_file: str) -> Config: config_path = None if config_file is None: for file in [DEFAULT_USER_CONFIG_FILE, DEFAULT_CONFIG_FILE]: path = Path(file).expanduser().resolve() if path.exists(): config_path = path break else: config_path = Path(config_file).expanduser().resolve() if not config_path.exists(): raise ConfigFileError( f"Config file {config_file} does not exist." ) config = Config() if config_path: config.load_from_config_file(config_path) return config def _set_defaults(self, config: ConfigDict) -> None: self.parser.set_defaults(**_to_defaults(config)) def parse_arguments( self, args: Optional[Sequence[str]] = None ) -> Namespace: """ Parse CLI arguments """ # Parse args to get the config file path passed as option known_args, _ = self.parser.parse_known_args(args) # Load the defaults from the config file if it exists. config = self._load_config(known_args.config) # set greenbone enterprise feed key in config if user passed one to load # desired key for determining the feed url if known_args.greenbone_enterprise_feed_key: config["greenbone-enterprise-feed-key"] = ( known_args.greenbone_enterprise_feed_key ) if self.parser.prog == "greenbone-nvt-sync": config["type"] = "nvt" elif self.parser.prog == "greenbone-scapdata-sync": config["type"] = "scap" elif self.parser.prog == "greenbone-certdata-sync": config["type"] = "cert" # apply defaults in config config.apply_settings() # check if a enterprise feed key is available enterprise_settings = self._determine_enterprise_settings( config["greenbone-enterprise-feed-key"] ) # override feed url from key if enterprise_settings: config["feed-url"] = enterprise_settings.feed_url() # apply other config defaults config.apply_dependent_settings() # set config as defaults for CLI to make them visible in --help self._set_defaults(config) if known_args.help: self.parser.print_help() self.parser.exit(0) return self.parser.parse_args(args) greenbone-feed-sync-24.3.0/greenbone/feed/sync/rsync.py000066400000000000000000000105641457600213200227600ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import asyncio import os from pathlib import Path from typing import Iterable, Optional, Union from urllib.parse import urlsplit from greenbone.feed.sync.errors import RsyncError async def exec_rsync(*args: str) -> None: """ Run rsync Argument: args: Arguments for rsync """ process = await asyncio.create_subprocess_exec( "rsync", *args, stderr=asyncio.subprocess.PIPE ) _, stderr = await process.communicate() returncode = await process.wait() if returncode: raise RsyncError(returncode, args, stderr=stderr) DEFAULT_RSYNC_URL = "rsync://feed.community.greenbone.net/community" DEFAULT_RSYNC_COMPRESSION_LEVEL = 9 DEFAULT_RSYNC_TIMEOUT: Optional[int] = ( None # in seconds. 0 means no timeout and None use rsync default ) DEFAULT_RSYNC_SSH_PORT = 24 DEFAULT_RSYNC_SSH_OPTS = ( "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" ) PathLike = Union[os.PathLike, str] class Rsync: """ Class to sync the feed data via rsync Args: verbose: Enable verbose output private_subdir: A private directory to exclude from from the sync compression_level: Set an compression level explicitly. Default is 9 (highest). timeout: Set a specific timeout in seconds. Default timeout of rsync is used of not set explicitly. 0 for no timeout. ssh_key: SSH key for using ssh as rsync transport protocol. exclude: An iterable of directories to exclude from the sync. """ def __init__( self, *, verbose: bool = False, private_subdir: Optional[PathLike] = None, compression_level: Optional[int] = DEFAULT_RSYNC_COMPRESSION_LEVEL, timeout: Optional[int] = DEFAULT_RSYNC_TIMEOUT, ssh_key: Optional[PathLike] = None, exclude: Optional[Iterable[PathLike]] = None, ) -> None: self.verbose = verbose self.private_subdir = private_subdir self.compression_level = compression_level self.timeout = timeout self.ssh_key = ssh_key self.exclude = exclude async def sync(self, url: str, destination: PathLike) -> None: """ Sync data from a remote URL to a destination path Args: url: URL to sync destination: Path to store the downloaded data """ dest = Path(destination) dest.mkdir(parents=True, exist_ok=True) splitted_url = urlsplit(url) rsync_default_options = [ "--links", "--times", "--omit-dir-times", "--recursive", "--partial", "--progress", ] if "ssh" in splitted_url.scheme: port = splitted_url.port or DEFAULT_RSYNC_SSH_PORT # we use ssh now rsync_ssh_options = [ "-e", f"ssh {DEFAULT_RSYNC_SSH_OPTS} -p {port} -i '{self.ssh_key}'", ] url = f"{splitted_url.netloc}:{splitted_url.path}" else: rsync_ssh_options = [] rsync_timeout = ( [ f"--timeout={self.timeout}", ] if self.timeout is not None else [] ) rsync_compress = ( [ f"--compress-level={self.compression_level}", ] if self.compression_level is not None else [] ) rsync_delete = [ "--delete", ] rsync_chmod = [ "--perms", "--chmod=Fugo+r,Fug+w,Dugo-s,Dugo+rx,Dug+w", ] rsync_links = [ "--copy-unsafe-links", "--hard-links", ] if self.private_subdir: rsync_delete.extend(["--exclude", os.fspath(self.private_subdir)]) if self.exclude: for exclude in self.exclude: rsync_delete.extend(["--exclude", os.fspath(exclude)]) rsync_verbose = ["-v"] if self.verbose else ["-q"] args = ( rsync_default_options + rsync_ssh_options + rsync_timeout + rsync_verbose + rsync_compress + rsync_delete + rsync_chmod + rsync_links + [url, str(dest.absolute())] ) await exec_rsync(*args) greenbone-feed-sync-24.3.0/poetry.lock000066400000000000000000001411051457600213200176150ustar00rootroot00000000000000# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "anyio" version = "4.3.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" optional = false python-versions = ">=3.8" files = [ {file = "anyio-4.3.0-py3-none-any.whl", hash = "sha256:048e05d0f6caeed70d731f3db756d35dcc1f35747c8c403364a8332c630441b8"}, {file = "anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6"}, ] [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 = "black" version = "24.3.0" description = "The uncompromising code formatter." optional = false python-versions = ">=3.8" files = [ {file = "black-24.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7d5e026f8da0322b5662fa7a8e752b3fa2dac1c1cbc213c3d7ff9bdd0ab12395"}, {file = "black-24.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9f50ea1132e2189d8dff0115ab75b65590a3e97de1e143795adb4ce317934995"}, {file = "black-24.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2af80566f43c85f5797365077fb64a393861a3730bd110971ab7a0c94e873e7"}, {file = "black-24.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:4be5bb28e090456adfc1255e03967fb67ca846a03be7aadf6249096100ee32d0"}, {file = "black-24.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4f1373a7808a8f135b774039f61d59e4be7eb56b2513d3d2f02a8b9365b8a8a9"}, {file = "black-24.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aadf7a02d947936ee418777e0247ea114f78aff0d0959461057cae8a04f20597"}, {file = "black-24.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c02e4ea2ae09d16314d30912a58ada9a5c4fdfedf9512d23326128ac08ac3d"}, {file = "black-24.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:bf21b7b230718a5f08bd32d5e4f1db7fc8788345c8aea1d155fc17852b3410f5"}, {file = "black-24.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2818cf72dfd5d289e48f37ccfa08b460bf469e67fb7c4abb07edc2e9f16fb63f"}, {file = "black-24.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4acf672def7eb1725f41f38bf6bf425c8237248bb0804faa3965c036f7672d11"}, {file = "black-24.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7ed6668cbbfcd231fa0dc1b137d3e40c04c7f786e626b405c62bcd5db5857e4"}, {file = "black-24.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:56f52cfbd3dabe2798d76dbdd299faa046a901041faf2cf33288bc4e6dae57b5"}, {file = "black-24.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:79dcf34b33e38ed1b17434693763301d7ccbd1c5860674a8f871bd15139e7837"}, {file = "black-24.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e19cb1c6365fd6dc38a6eae2dcb691d7d83935c10215aef8e6c38edee3f77abd"}, {file = "black-24.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b76c275e4c1c5ce6e9870911384bff5ca31ab63d19c76811cb1fb162678213"}, {file = "black-24.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:b5991d523eee14756f3c8d5df5231550ae8993e2286b8014e2fdea7156ed0959"}, {file = "black-24.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c45f8dff244b3c431b36e3224b6be4a127c6aca780853574c00faf99258041eb"}, {file = "black-24.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6905238a754ceb7788a73f02b45637d820b2f5478b20fec82ea865e4f5d4d9f7"}, {file = "black-24.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7de8d330763c66663661a1ffd432274a2f92f07feeddd89ffd085b5744f85e7"}, {file = "black-24.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:7bb041dca0d784697af4646d3b62ba4a6b028276ae878e53f6b4f74ddd6db99f"}, {file = "black-24.3.0-py3-none-any.whl", hash = "sha256:41622020d7120e01d377f74249e677039d20e6344ff5851de8a10f11f513bf93"}, {file = "black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f"}, ] [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.2.2" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" files = [ {file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"}, {file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"}, ] [[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.4.4" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" files = [ {file = "coverage-7.4.4-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0be5efd5127542ef31f165de269f77560d6cdef525fffa446de6f7e9186cfb2"}, {file = "coverage-7.4.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ccd341521be3d1b3daeb41960ae94a5e87abe2f46f17224ba5d6f2b8398016cf"}, {file = "coverage-7.4.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:09fa497a8ab37784fbb20ab699c246053ac294d13fc7eb40ec007a5043ec91f8"}, {file = "coverage-7.4.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b1a93009cb80730c9bca5d6d4665494b725b6e8e157c1cb7f2db5b4b122ea562"}, {file = "coverage-7.4.4-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:690db6517f09336559dc0b5f55342df62370a48f5469fabf502db2c6d1cffcd2"}, {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:09c3255458533cb76ef55da8cc49ffab9e33f083739c8bd4f58e79fecfe288f7"}, {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:8ce1415194b4a6bd0cdcc3a1dfbf58b63f910dcb7330fe15bdff542c56949f87"}, {file = "coverage-7.4.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b91cbc4b195444e7e258ba27ac33769c41b94967919f10037e6355e998af255c"}, {file = "coverage-7.4.4-cp310-cp310-win32.whl", hash = "sha256:598825b51b81c808cb6f078dcb972f96af96b078faa47af7dfcdf282835baa8d"}, {file = "coverage-7.4.4-cp310-cp310-win_amd64.whl", hash = "sha256:09ef9199ed6653989ebbcaacc9b62b514bb63ea2f90256e71fea3ed74bd8ff6f"}, {file = "coverage-7.4.4-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:0f9f50e7ef2a71e2fae92774c99170eb8304e3fdf9c8c3c7ae9bab3e7229c5cf"}, {file = "coverage-7.4.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:623512f8ba53c422fcfb2ce68362c97945095b864cda94a92edbaf5994201083"}, {file = "coverage-7.4.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0513b9508b93da4e1716744ef6ebc507aff016ba115ffe8ecff744d1322a7b63"}, {file = "coverage-7.4.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:40209e141059b9370a2657c9b15607815359ab3ef9918f0196b6fccce8d3230f"}, {file = "coverage-7.4.4-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8a2b2b78c78293782fd3767d53e6474582f62443d0504b1554370bde86cc8227"}, {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:73bfb9c09951125d06ee473bed216e2c3742f530fc5acc1383883125de76d9cd"}, {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:1f384c3cc76aeedce208643697fb3e8437604b512255de6d18dae3f27655a384"}, {file = "coverage-7.4.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:54eb8d1bf7cacfbf2a3186019bcf01d11c666bd495ed18717162f7eb1e9dd00b"}, {file = "coverage-7.4.4-cp311-cp311-win32.whl", hash = "sha256:cac99918c7bba15302a2d81f0312c08054a3359eaa1929c7e4b26ebe41e9b286"}, {file = "coverage-7.4.4-cp311-cp311-win_amd64.whl", hash = "sha256:b14706df8b2de49869ae03a5ccbc211f4041750cd4a66f698df89d44f4bd30ec"}, {file = "coverage-7.4.4-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:201bef2eea65e0e9c56343115ba3814e896afe6d36ffd37bab783261db430f76"}, {file = "coverage-7.4.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:41c9c5f3de16b903b610d09650e5e27adbfa7f500302718c9ffd1c12cf9d6818"}, {file = "coverage-7.4.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d898fe162d26929b5960e4e138651f7427048e72c853607f2b200909794ed978"}, {file = "coverage-7.4.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3ea79bb50e805cd6ac058dfa3b5c8f6c040cb87fe83de10845857f5535d1db70"}, {file = "coverage-7.4.4-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ce4b94265ca988c3f8e479e741693d143026632672e3ff924f25fab50518dd51"}, {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:00838a35b882694afda09f85e469c96367daa3f3f2b097d846a7216993d37f4c"}, {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:fdfafb32984684eb03c2d83e1e51f64f0906b11e64482df3c5db936ce3839d48"}, {file = "coverage-7.4.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:69eb372f7e2ece89f14751fbcbe470295d73ed41ecd37ca36ed2eb47512a6ab9"}, {file = "coverage-7.4.4-cp312-cp312-win32.whl", hash = "sha256:137eb07173141545e07403cca94ab625cc1cc6bc4c1e97b6e3846270e7e1fea0"}, {file = "coverage-7.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:d71eec7d83298f1af3326ce0ff1d0ea83c7cb98f72b577097f9083b20bdaf05e"}, {file = "coverage-7.4.4-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d5ae728ff3b5401cc320d792866987e7e7e880e6ebd24433b70a33b643bb0384"}, {file = "coverage-7.4.4-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:cc4f1358cb0c78edef3ed237ef2c86056206bb8d9140e73b6b89fbcfcbdd40e1"}, {file = "coverage-7.4.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8130a2aa2acb8788e0b56938786c33c7c98562697bf9f4c7d6e8e5e3a0501e4a"}, {file = "coverage-7.4.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cf271892d13e43bc2b51e6908ec9a6a5094a4df1d8af0bfc360088ee6c684409"}, {file = "coverage-7.4.4-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a4cdc86d54b5da0df6d3d3a2f0b710949286094c3a6700c21e9015932b81447e"}, {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:ae71e7ddb7a413dd60052e90528f2f65270aad4b509563af6d03d53e979feafd"}, {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:38dd60d7bf242c4ed5b38e094baf6401faa114fc09e9e6632374388a404f98e7"}, {file = "coverage-7.4.4-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:aa5b1c1bfc28384f1f53b69a023d789f72b2e0ab1b3787aae16992a7ca21056c"}, {file = "coverage-7.4.4-cp38-cp38-win32.whl", hash = "sha256:dfa8fe35a0bb90382837b238fff375de15f0dcdb9ae68ff85f7a63649c98527e"}, {file = "coverage-7.4.4-cp38-cp38-win_amd64.whl", hash = "sha256:b2991665420a803495e0b90a79233c1433d6ed77ef282e8e152a324bbbc5e0c8"}, {file = "coverage-7.4.4-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3b799445b9f7ee8bf299cfaed6f5b226c0037b74886a4e11515e569b36fe310d"}, {file = "coverage-7.4.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:b4d33f418f46362995f1e9d4f3a35a1b6322cb959c31d88ae56b0298e1c22357"}, {file = "coverage-7.4.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aadacf9a2f407a4688d700e4ebab33a7e2e408f2ca04dbf4aef17585389eff3e"}, {file = "coverage-7.4.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:7c95949560050d04d46b919301826525597f07b33beba6187d04fa64d47ac82e"}, {file = "coverage-7.4.4-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ff7687ca3d7028d8a5f0ebae95a6e4827c5616b31a4ee1192bdfde697db110d4"}, {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:5fc1de20b2d4a061b3df27ab9b7c7111e9a710f10dc2b84d33a4ab25065994ec"}, {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:c74880fc64d4958159fbd537a091d2a585448a8f8508bf248d72112723974cbd"}, {file = "coverage-7.4.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:742a76a12aa45b44d236815d282b03cfb1de3b4323f3e4ec933acfae08e54ade"}, {file = "coverage-7.4.4-cp39-cp39-win32.whl", hash = "sha256:d89d7b2974cae412400e88f35d86af72208e1ede1a541954af5d944a8ba46c57"}, {file = "coverage-7.4.4-cp39-cp39-win_amd64.whl", hash = "sha256:9ca28a302acb19b6af89e90f33ee3e1906961f94b54ea37de6737b7ca9d8827c"}, {file = "coverage-7.4.4-pp38.pp39.pp310-none-any.whl", hash = "sha256:b2c5edc4ac10a7ef6605a966c58929ec6c1bd0917fb8c15cb3363f65aa40e677"}, {file = "coverage-7.4.4.tar.gz", hash = "sha256:c901df83d097649e257e803be22592aedfd5182f07b3cc87d640bbb9afd50f49"}, ] [package.dependencies] tomli = {version = "*", optional = true, markers = "python_full_version <= \"3.11.0a6\" and extra == \"toml\""} [package.extras] toml = ["tomli"] [[package]] name = "exceptiongroup" version = "1.2.0" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" files = [ {file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"}, {file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"}, ] [package.extras] test = ["pytest (>=6)"] [[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.4" description = "A minimal low-level HTTP client." optional = false python-versions = ">=3.8" files = [ {file = "httpcore-1.0.4-py3-none-any.whl", hash = "sha256:ac418c1db41bade2ad53ae2f3834a3a0f5ae76b56cf5aa497d2d033384fc7d73"}, {file = "httpcore-1.0.4.tar.gz", hash = "sha256:cb2839ccfcba0d2d3c1131d3c3e26dfc327326fbe7a5dc0dbfe9f6c9151bb022"}, ] [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.25.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.6" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.5" files = [ {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, ] [[package]] name = "lxml" version = "5.1.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.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:704f5572ff473a5f897745abebc6df40f22d4133c1e0a1f124e4f2bd3330ff7e"}, {file = "lxml-5.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:9d3c0f8567ffe7502d969c2c1b809892dc793b5d0665f602aad19895f8d508da"}, {file = "lxml-5.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:5fcfbebdb0c5d8d18b84118842f31965d59ee3e66996ac842e21f957eb76138c"}, {file = "lxml-5.1.0-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2f37c6d7106a9d6f0708d4e164b707037b7380fcd0b04c5bd9cae1fb46a856fb"}, {file = "lxml-5.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2befa20a13f1a75c751f47e00929fb3433d67eb9923c2c0b364de449121f447c"}, {file = "lxml-5.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:22b7ee4c35f374e2c20337a95502057964d7e35b996b1c667b5c65c567d2252a"}, {file = "lxml-5.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:bf8443781533b8d37b295016a4b53c1494fa9a03573c09ca5104550c138d5c05"}, {file = "lxml-5.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:82bddf0e72cb2af3cbba7cec1d2fd11fda0de6be8f4492223d4a268713ef2147"}, {file = "lxml-5.1.0-cp310-cp310-win32.whl", hash = "sha256:b66aa6357b265670bb574f050ffceefb98549c721cf28351b748be1ef9577d93"}, {file = "lxml-5.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:4946e7f59b7b6a9e27bef34422f645e9a368cb2be11bf1ef3cafc39a1f6ba68d"}, {file = "lxml-5.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:14deca1460b4b0f6b01f1ddc9557704e8b365f55c63070463f6c18619ebf964f"}, {file = "lxml-5.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ed8c3d2cd329bf779b7ed38db176738f3f8be637bb395ce9629fc76f78afe3d4"}, {file = "lxml-5.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:436a943c2900bb98123b06437cdd30580a61340fbdb7b28aaf345a459c19046a"}, {file = "lxml-5.1.0-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:acb6b2f96f60f70e7f34efe0c3ea34ca63f19ca63ce90019c6cbca6b676e81fa"}, {file = "lxml-5.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:af8920ce4a55ff41167ddbc20077f5698c2e710ad3353d32a07d3264f3a2021e"}, {file = "lxml-5.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7cfced4a069003d8913408e10ca8ed092c49a7f6cefee9bb74b6b3e860683b45"}, {file = "lxml-5.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:9e5ac3437746189a9b4121db2a7b86056ac8786b12e88838696899328fc44bb2"}, {file = "lxml-5.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:f4c9bda132ad108b387c33fabfea47866af87f4ea6ffb79418004f0521e63204"}, {file = "lxml-5.1.0-cp311-cp311-win32.whl", hash = "sha256:bc64d1b1dab08f679fb89c368f4c05693f58a9faf744c4d390d7ed1d8223869b"}, {file = "lxml-5.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:a5ab722ae5a873d8dcee1f5f45ddd93c34210aed44ff2dc643b5025981908cda"}, {file = "lxml-5.1.0-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:9aa543980ab1fbf1720969af1d99095a548ea42e00361e727c58a40832439114"}, {file = "lxml-5.1.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:6f11b77ec0979f7e4dc5ae081325a2946f1fe424148d3945f943ceaede98adb8"}, {file = "lxml-5.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a36c506e5f8aeb40680491d39ed94670487ce6614b9d27cabe45d94cd5d63e1e"}, {file = "lxml-5.1.0-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:f643ffd2669ffd4b5a3e9b41c909b72b2a1d5e4915da90a77e119b8d48ce867a"}, {file = "lxml-5.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:16dd953fb719f0ffc5bc067428fc9e88f599e15723a85618c45847c96f11f431"}, {file = "lxml-5.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:16018f7099245157564d7148165132c70adb272fb5a17c048ba70d9cc542a1a1"}, {file = "lxml-5.1.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:82cd34f1081ae4ea2ede3d52f71b7be313756e99b4b5f829f89b12da552d3aa3"}, {file = "lxml-5.1.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:19a1bc898ae9f06bccb7c3e1dfd73897ecbbd2c96afe9095a6026016e5ca97b8"}, {file = "lxml-5.1.0-cp312-cp312-win32.whl", hash = "sha256:13521a321a25c641b9ea127ef478b580b5ec82aa2e9fc076c86169d161798b01"}, {file = "lxml-5.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:1ad17c20e3666c035db502c78b86e58ff6b5991906e55bdbef94977700c72623"}, {file = "lxml-5.1.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:24ef5a4631c0b6cceaf2dbca21687e29725b7c4e171f33a8f8ce23c12558ded1"}, {file = "lxml-5.1.0-cp36-cp36m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8d2900b7f5318bc7ad8631d3d40190b95ef2aa8cc59473b73b294e4a55e9f30f"}, {file = "lxml-5.1.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:601f4a75797d7a770daed8b42b97cd1bb1ba18bd51a9382077a6a247a12aa38d"}, {file = "lxml-5.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b4b68c961b5cc402cbd99cca5eb2547e46ce77260eb705f4d117fd9c3f932b95"}, {file = "lxml-5.1.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:afd825e30f8d1f521713a5669b63657bcfe5980a916c95855060048b88e1adb7"}, {file = "lxml-5.1.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:262bc5f512a66b527d026518507e78c2f9c2bd9eb5c8aeeb9f0eb43fcb69dc67"}, {file = "lxml-5.1.0-cp36-cp36m-win32.whl", hash = "sha256:e856c1c7255c739434489ec9c8aa9cdf5179785d10ff20add308b5d673bed5cd"}, {file = "lxml-5.1.0-cp36-cp36m-win_amd64.whl", hash = "sha256:c7257171bb8d4432fe9d6fdde4d55fdbe663a63636a17f7f9aaba9bcb3153ad7"}, {file = "lxml-5.1.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:b9e240ae0ba96477682aa87899d94ddec1cc7926f9df29b1dd57b39e797d5ab5"}, {file = "lxml-5.1.0-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:a96f02ba1bcd330807fc060ed91d1f7a20853da6dd449e5da4b09bfcc08fdcf5"}, {file = "lxml-5.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3e3898ae2b58eeafedfe99e542a17859017d72d7f6a63de0f04f99c2cb125936"}, {file = "lxml-5.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61c5a7edbd7c695e54fca029ceb351fc45cd8860119a0f83e48be44e1c464862"}, {file = "lxml-5.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:3aeca824b38ca78d9ee2ab82bd9883083d0492d9d17df065ba3b94e88e4d7ee6"}, {file = "lxml-5.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:8f52fe6859b9db71ee609b0c0a70fea5f1e71c3462ecf144ca800d3f434f0764"}, {file = "lxml-5.1.0-cp37-cp37m-win32.whl", hash = "sha256:d42e3a3fc18acc88b838efded0e6ec3edf3e328a58c68fbd36a7263a874906c8"}, {file = "lxml-5.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:eac68f96539b32fce2c9b47eb7c25bb2582bdaf1bbb360d25f564ee9e04c542b"}, {file = "lxml-5.1.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:ae15347a88cf8af0949a9872b57a320d2605ae069bcdf047677318bc0bba45b1"}, {file = "lxml-5.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:c26aab6ea9c54d3bed716b8851c8bfc40cb249b8e9880e250d1eddde9f709bf5"}, {file = "lxml-5.1.0-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:342e95bddec3a698ac24378d61996b3ee5ba9acfeb253986002ac53c9a5f6f84"}, {file = "lxml-5.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:725e171e0b99a66ec8605ac77fa12239dbe061482ac854d25720e2294652eeaa"}, {file = "lxml-5.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3d184e0d5c918cff04cdde9dbdf9600e960161d773666958c9d7b565ccc60c45"}, {file = "lxml-5.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:98f3f020a2b736566c707c8e034945c02aa94e124c24f77ca097c446f81b01f1"}, {file = "lxml-5.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6d48fc57e7c1e3df57be5ae8614bab6d4e7b60f65c5457915c26892c41afc59e"}, {file = "lxml-5.1.0-cp38-cp38-win32.whl", hash = "sha256:7ec465e6549ed97e9f1e5ed51c657c9ede767bc1c11552f7f4d022c4df4a977a"}, {file = "lxml-5.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:b21b4031b53d25b0858d4e124f2f9131ffc1530431c6d1321805c90da78388d1"}, {file = "lxml-5.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:52427a7eadc98f9e62cb1368a5079ae826f94f05755d2d567d93ee1bc3ceb354"}, {file = "lxml-5.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6a2a2c724d97c1eb8cf966b16ca2915566a4904b9aad2ed9a09c748ffe14f969"}, {file = "lxml-5.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:843b9c835580d52828d8f69ea4302537337a21e6b4f1ec711a52241ba4a824f3"}, {file = "lxml-5.1.0-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9b99f564659cfa704a2dd82d0684207b1aadf7d02d33e54845f9fc78e06b7581"}, {file = "lxml-5.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4f8b0c78e7aac24979ef09b7f50da871c2de2def043d468c4b41f512d831e912"}, {file = "lxml-5.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9bcf86dfc8ff3e992fed847c077bd875d9e0ba2fa25d859c3a0f0f76f07f0c8d"}, {file = "lxml-5.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:49a9b4af45e8b925e1cd6f3b15bbba2c81e7dba6dce170c677c9cda547411e14"}, {file = "lxml-5.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:280f3edf15c2a967d923bcfb1f8f15337ad36f93525828b40a0f9d6c2ad24890"}, {file = "lxml-5.1.0-cp39-cp39-win32.whl", hash = "sha256:ed7326563024b6e91fef6b6c7a1a2ff0a71b97793ac33dbbcf38f6005e51ff6e"}, {file = "lxml-5.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:8d7b4beebb178e9183138f552238f7e6613162a42164233e2bda00cb3afac58f"}, {file = "lxml-5.1.0-pp310-pypy310_pp73-macosx_10_9_x86_64.whl", hash = "sha256:9bd0ae7cc2b85320abd5e0abad5ccee5564ed5f0cc90245d2f9a8ef330a8deae"}, {file = "lxml-5.1.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d8c1d679df4361408b628f42b26a5d62bd3e9ba7f0c0e7969f925021554755aa"}, {file = "lxml-5.1.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:2ad3a8ce9e8a767131061a22cd28fdffa3cd2dc193f399ff7b81777f3520e372"}, {file = "lxml-5.1.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl", hash = "sha256:304128394c9c22b6569eba2a6d98392b56fbdfbad58f83ea702530be80d0f9df"}, {file = "lxml-5.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d74fcaf87132ffc0447b3c685a9f862ffb5b43e70ea6beec2fb8057d5d2a1fea"}, {file = "lxml-5.1.0-pp37-pypy37_pp73-win_amd64.whl", hash = "sha256:8cf5877f7ed384dabfdcc37922c3191bf27e55b498fecece9fd5c2c7aaa34c33"}, {file = "lxml-5.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl", hash = "sha256:877efb968c3d7eb2dad540b6cabf2f1d3c0fbf4b2d309a3c141f79c7e0061324"}, {file = "lxml-5.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3f14a4fb1c1c402a22e6a341a24c1341b4a3def81b41cd354386dcb795f83897"}, {file = "lxml-5.1.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:25663d6e99659544ee8fe1b89b1a8c0aaa5e34b103fab124b17fa958c4a324a6"}, {file = "lxml-5.1.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl", hash = "sha256:8b9f19df998761babaa7f09e6bc169294eefafd6149aaa272081cbddc7ba4ca3"}, {file = "lxml-5.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e53d7e6a98b64fe54775d23a7c669763451340c3d44ad5e3a3b48a1efbdc96f"}, {file = "lxml-5.1.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:c3cd1fc1dc7c376c54440aeaaa0dcc803d2126732ff5c6b68ccd619f2e64be4f"}, {file = "lxml-5.1.0.tar.gz", hash = "sha256:3eea6ed6e6c918e468e693c41ef07f3c3acc310b70ddd9cc72d9ef84bc9564ca"}, ] [package.extras] cssselect = ["cssselect (>=0.7)"] html5 = ["html5lib"] htmlsoup = ["BeautifulSoup4"] source = ["Cython (>=3.0.7)"] [[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 = "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.9.0" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ {file = "mypy-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f8a67616990062232ee4c3952f41c779afac41405806042a8126fe96e098419f"}, {file = "mypy-1.9.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d357423fa57a489e8c47b7c85dfb96698caba13d66e086b412298a1a0ea3b0ed"}, {file = "mypy-1.9.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:49c87c15aed320de9b438ae7b00c1ac91cd393c1b854c2ce538e2a72d55df150"}, {file = "mypy-1.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:48533cdd345c3c2e5ef48ba3b0d3880b257b423e7995dada04248725c6f77374"}, {file = "mypy-1.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:4d3dbd346cfec7cb98e6cbb6e0f3c23618af826316188d587d1c1bc34f0ede03"}, {file = "mypy-1.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:653265f9a2784db65bfca694d1edd23093ce49740b2244cde583aeb134c008f3"}, {file = "mypy-1.9.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3a3c007ff3ee90f69cf0a15cbcdf0995749569b86b6d2f327af01fd1b8aee9dc"}, {file = "mypy-1.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2418488264eb41f69cc64a69a745fad4a8f86649af4b1041a4c64ee61fc61129"}, {file = "mypy-1.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:68edad3dc7d70f2f17ae4c6c1b9471a56138ca22722487eebacfd1eb5321d612"}, {file = "mypy-1.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:85ca5fcc24f0b4aeedc1d02f93707bccc04733f21d41c88334c5482219b1ccb3"}, {file = "mypy-1.9.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aceb1db093b04db5cd390821464504111b8ec3e351eb85afd1433490163d60cd"}, {file = "mypy-1.9.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0235391f1c6f6ce487b23b9dbd1327b4ec33bb93934aa986efe8a9563d9349e6"}, {file = "mypy-1.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d4d5ddc13421ba3e2e082a6c2d74c2ddb3979c39b582dacd53dd5d9431237185"}, {file = "mypy-1.9.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:190da1ee69b427d7efa8aa0d5e5ccd67a4fb04038c380237a0d96829cb157913"}, {file = "mypy-1.9.0-cp312-cp312-win_amd64.whl", hash = "sha256:fe28657de3bfec596bbeef01cb219833ad9d38dd5393fc649f4b366840baefe6"}, {file = "mypy-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:e54396d70be04b34f31d2edf3362c1edd023246c82f1730bbf8768c28db5361b"}, {file = "mypy-1.9.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:5e6061f44f2313b94f920e91b204ec600982961e07a17e0f6cd83371cb23f5c2"}, {file = "mypy-1.9.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:81a10926e5473c5fc3da8abb04119a1f5811a236dc3a38d92015cb1e6ba4cb9e"}, {file = "mypy-1.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:b685154e22e4e9199fc95f298661deea28aaede5ae16ccc8cbb1045e716b3e04"}, {file = "mypy-1.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:5d741d3fc7c4da608764073089e5f58ef6352bedc223ff58f2f038c2c4698a89"}, {file = "mypy-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:587ce887f75dd9700252a3abbc9c97bbe165a4a630597845c61279cf32dfbf02"}, {file = "mypy-1.9.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f88566144752999351725ac623471661c9d1cd8caa0134ff98cceeea181789f4"}, {file = "mypy-1.9.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:61758fabd58ce4b0720ae1e2fea5cfd4431591d6d590b197775329264f86311d"}, {file = "mypy-1.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:e49499be624dead83927e70c756970a0bc8240e9f769389cdf5714b0784ca6bf"}, {file = "mypy-1.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:571741dc4194b4f82d344b15e8837e8c5fcc462d66d076748142327626a1b6e9"}, {file = "mypy-1.9.0-py3-none-any.whl", hash = "sha256:a260627a570559181a9ea5de61ac6297aa5af202f06fd7ab093ce74e7181e43e"}, {file = "mypy-1.9.0.tar.gz", hash = "sha256:3cc5da0127e6a478cddd906068496a97a7618a21ce9b54bde5bf7e539c7af974"}, ] [package.dependencies] mypy-extensions = ">=1.0.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} typing-extensions = ">=4.1.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.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.7" files = [ {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, ] [[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.0" 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.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, ] [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)"] [[package]] name = "pontos" version = "24.3.1" description = "Common utilities and tools maintained by Greenbone Networks" optional = false python-versions = ">=3.9,<4.0" files = [ {file = "pontos-24.3.1-py3-none-any.whl", hash = "sha256:9561fd69a0a0e14b9cb802dece0c3d090d88094363a6b8df526e2fcff3c48255"}, {file = "pontos-24.3.1.tar.gz", hash = "sha256:df05a7703686b227053750c4855dcb622640a598103538fcc8691b1624678aa0"}, ] [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 = "pygments" version = "2.17.2" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.7" files = [ {file = "pygments-2.17.2-py3-none-any.whl", hash = "sha256:b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c"}, {file = "pygments-2.17.2.tar.gz", hash = "sha256:da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"}, ] [package.extras] plugins = ["importlib-metadata"] windows-terminal = ["colorama (>=0.4.6)"] [[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 = "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.3.3" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ {file = "ruff-0.3.3-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:973a0e388b7bc2e9148c7f9be8b8c6ae7471b9be37e1cc732f8f44a6f6d7720d"}, {file = "ruff-0.3.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cfa60d23269d6e2031129b053fdb4e5a7b0637fc6c9c0586737b962b2f834493"}, {file = "ruff-0.3.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1eca7ff7a47043cf6ce5c7f45f603b09121a7cc047447744b029d1b719278eb5"}, {file = "ruff-0.3.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e7d3f6762217c1da954de24b4a1a70515630d29f71e268ec5000afe81377642d"}, {file = "ruff-0.3.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b24c19e8598916d9c6f5a5437671f55ee93c212a2c4c569605dc3842b6820386"}, {file = "ruff-0.3.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5a6cbf216b69c7090f0fe4669501a27326c34e119068c1494f35aaf4cc683778"}, {file = "ruff-0.3.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:352e95ead6964974b234e16ba8a66dad102ec7bf8ac064a23f95371d8b198aab"}, {file = "ruff-0.3.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d6ab88c81c4040a817aa432484e838aaddf8bfd7ca70e4e615482757acb64f8"}, {file = "ruff-0.3.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:79bca3a03a759cc773fca69e0bdeac8abd1c13c31b798d5bb3c9da4a03144a9f"}, {file = "ruff-0.3.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2700a804d5336bcffe063fd789ca2c7b02b552d2e323a336700abb8ae9e6a3f8"}, {file = "ruff-0.3.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:fd66469f1a18fdb9d32e22b79f486223052ddf057dc56dea0caaf1a47bdfaf4e"}, {file = "ruff-0.3.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:45817af234605525cdf6317005923bf532514e1ea3d9270acf61ca2440691376"}, {file = "ruff-0.3.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:0da458989ce0159555ef224d5b7c24d3d2e4bf4c300b85467b08c3261c6bc6a8"}, {file = "ruff-0.3.3-py3-none-win32.whl", hash = "sha256:f2831ec6a580a97f1ea82ea1eda0401c3cdf512cf2045fa3c85e8ef109e87de0"}, {file = "ruff-0.3.3-py3-none-win_amd64.whl", hash = "sha256:be90bcae57c24d9f9d023b12d627e958eb55f595428bafcb7fec0791ad25ddfc"}, {file = "ruff-0.3.3-py3-none-win_arm64.whl", hash = "sha256:0171aab5fecdc54383993389710a3d1227f2da124d76a2784a7098e818f92d61"}, {file = "ruff-0.3.3.tar.gz", hash = "sha256:38671be06f57a2f8aba957d9f701ea889aa5736be806f18c0cd03d6ff0cbca8d"}, ] [[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 = "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.12.4" description = "Style preserving TOML library" optional = false python-versions = ">=3.7" files = [ {file = "tomlkit-0.12.4-py3-none-any.whl", hash = "sha256:5cd82d48a3dd89dee1f9d64420aa20ae65cfbd00668d6f094d7578a78efbb77b"}, {file = "tomlkit-0.12.4.tar.gz", hash = "sha256:7ca1cfc12232806517a8515047ba66a19369e71edf2439d0f5824f91032b6cc3"}, ] [[package]] name = "typing-extensions" version = "4.10.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, ] [metadata] lock-version = "2.0" python-versions = "^3.9" content-hash = "fcb76399a3238b2d08d22b5989b8923506ea2a0375440dfcb1ef7e891ecff9ca" greenbone-feed-sync-24.3.0/pyproject.toml000066400000000000000000000043611457600213200203370ustar00rootroot00000000000000[tool.poetry] name = "greenbone-feed-sync" version = "24.3.0" description = "A tool for downloading the Greenbone Community Feed" authors = ["Björn Ricks "] license = "GPL-3.0-or-later" readme = "README.md" 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+)", # pylint: disable=line-too-long "Environment :: Console", "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 :: Utilities", ] packages = [ { include = "greenbone" }, { include = "tests", format = "sdist" }, { include = "poetry.lock", format = "sdist" }, ] [tool.poetry.dependencies] python = "^3.9" rich = ">=13.2.0" tomli = { version = ">=2.0.1", python = "<3.11" } shtab = ">=1.6.5" [tool.poetry.group.dev.dependencies] autohooks-plugin-black = ">=22.11.0" autohooks-plugin-ruff = ">=23.6.0" autohooks-plugin-mypy = ">=23.3.0" pontos = ">=22.12.2" coverage = { extras = ["toml"], version = ">=7.1.0" } [tool.poetry.scripts] greenbone-feed-sync = 'greenbone.feed.sync.main:main' greenbone-nvt-sync = 'greenbone.feed.sync.main:main' greenbone-scapdata-sync = 'greenbone.feed.sync.main:main' greenbone-certdata-sync = 'greenbone.feed.sync.main:main' [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" [tool.black] line-length = 80 target-version = ['py39', 'py310', 'py311', 'py312'] exclude = ''' /( \.git | \.venv | \.github | \.vscode | _build | build | dist | docs )/ ''' [tool.autohooks] pre-commit = [ 'autohooks.plugins.black', 'autohooks.plugins.ruff', 'autohooks.plugins.mypy', ] mode = "poetry" [tool.pontos.version] version-module-file = "greenbone/feed/sync/__version__.py" [tool.isort] profile = "black" line_length = 80 [tool.ruff] line-length = 80 target-version = "py39" extend-select = ["I", "PLE", "PLW"] [tool.coverage.run] omit = ["tests/*", "*/__init__.py"] source = ["greenbone"] [tool.mypy] files = "greenbone" ignore_missing_imports = true explicit_package_bases = true greenbone-feed-sync-24.3.0/tests/000077500000000000000000000000001457600213200165615ustar00rootroot00000000000000greenbone-feed-sync-24.3.0/tests/__init__.py000066400000000000000000000001411457600213200206660ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2022-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # greenbone-feed-sync-24.3.0/tests/test_config.py000066400000000000000000000600011457600213200214340ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # # pylint: disable=line-too-long # ruff: noqa: E501 import unittest from pathlib import Path from unittest.mock import MagicMock, patch from pontos.testing import temp_file from greenbone.feed.sync.config import ( DEFAULT_CERT_DATA_PATH, DEFAULT_CERT_DATA_URL_PATH, DEFAULT_DESTINATION_PREFIX, DEFAULT_ENTERPRISE_KEY_PATH, DEFAULT_GROUP, DEFAULT_GVMD_DATA_PATH, DEFAULT_GVMD_DATA_URL_PATH, DEFAULT_GVMD_LOCK_FILE_PATH, DEFAULT_NASL_PATH, DEFAULT_NASL_URL_PATH, DEFAULT_NOTUS_PATH, DEFAULT_NOTUS_URL_PATH, DEFAULT_OPENVAS_LOCK_FILE_PATH, DEFAULT_PORT_LISTS_PATH, DEFAULT_PORT_LISTS_URL_PATH, DEFAULT_REPORT_FORMATS_PATH, DEFAULT_REPORT_FORMATS_URL_PATH, DEFAULT_SCAN_CONFIGS_PATH, DEFAULT_SCAN_CONFIGS_URL_PATH, DEFAULT_SCAP_DATA_PATH, DEFAULT_SCAP_DATA_URL_PATH, DEFAULT_USER, DEFAULT_VERSION, Config, EnterpriseSettings, ) from greenbone.feed.sync.errors import ConfigFileError from greenbone.feed.sync.helper import DEFAULT_FLOCK_WAIT_INTERVAL from greenbone.feed.sync.rsync import ( DEFAULT_RSYNC_COMPRESSION_LEVEL, DEFAULT_RSYNC_URL, ) class ConfigTestCase(unittest.TestCase): def test_defaults(self): values = Config.load() self.assertEqual(len(values), 30) self.assertEqual( values["destination-prefix"], Path(DEFAULT_DESTINATION_PREFIX) ) self.assertEqual( values["gvmd-data-destination"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_GVMD_DATA_PATH, ) self.assertEqual( values["gvmd-data-url"], f"{DEFAULT_RSYNC_URL}{DEFAULT_GVMD_DATA_URL_PATH}", ) self.assertEqual(values["feed-url"], DEFAULT_RSYNC_URL) self.assertEqual( values["notus-destination"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_NOTUS_PATH, ) self.assertEqual( values["notus-url"], f"{DEFAULT_RSYNC_URL}{DEFAULT_NOTUS_URL_PATH}" ) self.assertEqual( values["nasl-destination"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_NASL_PATH, ) self.assertEqual( values["nasl-url"], f"{DEFAULT_RSYNC_URL}{DEFAULT_NASL_URL_PATH}" ) self.assertEqual( values["scap-data-destination"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_SCAP_DATA_PATH, ) self.assertEqual( values["scap-data-url"], f"{DEFAULT_RSYNC_URL}{DEFAULT_SCAP_DATA_URL_PATH}", ) self.assertEqual( values["cert-data-destination"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_CERT_DATA_PATH, ) self.assertEqual( values["cert-data-url"], f"{DEFAULT_RSYNC_URL}{DEFAULT_CERT_DATA_URL_PATH}", ) self.assertEqual( values["report-formats-destination"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_REPORT_FORMATS_PATH, ) self.assertEqual( values["report-formats-url"], f"{DEFAULT_RSYNC_URL}{DEFAULT_REPORT_FORMATS_URL_PATH}", ) self.assertEqual( values["scan-configs-destination"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_SCAN_CONFIGS_PATH, ) self.assertEqual( values["scan-configs-url"], f"{DEFAULT_RSYNC_URL}{DEFAULT_SCAN_CONFIGS_URL_PATH}", ) self.assertEqual( values["port-lists-destination"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_PORT_LISTS_PATH, ) self.assertEqual( values["port-lists-url"], f"{DEFAULT_RSYNC_URL}{DEFAULT_PORT_LISTS_URL_PATH}", ) self.assertEqual( values["gvmd-lock-file"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_GVMD_LOCK_FILE_PATH, ) self.assertEqual( values["openvas-lock-file"], Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_OPENVAS_LOCK_FILE_PATH, ) self.assertEqual(values["wait-interval"], DEFAULT_FLOCK_WAIT_INTERVAL) self.assertFalse(values["no-wait"]) self.assertEqual( values["compression-level"], DEFAULT_RSYNC_COMPRESSION_LEVEL ) self.assertIsNone(values["private-directory"]) self.assertIsNone(values["verbose"]) self.assertFalse(values["fail-fast"]) self.assertIsNone(values["rsync-timeout"]) self.assertEqual(values["group"], DEFAULT_GROUP) self.assertEqual(values["user"], DEFAULT_USER) self.assertEqual( values["greenbone-enterprise-feed-key"], Path(DEFAULT_ENTERPRISE_KEY_PATH), ) def test_config_file(self): content = """[greenbone-feed-sync] destination-prefix = "/opt/lib" feed-url = "rsync://lorem.ipsum" gvmd-data-destination = "/usr/lib/gvmd-data" gvmd-data-url = "rsync://foo.bar/gvmd-data" notus-destination = "/usr/lib/notus" notus-url = "rsync://foo.bar/notus" nasl-destination = "/usr/lib/openvas/plugins/" nasl-url = "rsync://foo.bar/nasl" scap-data-destination = "/usr/lib/scap-data" scap-data-url = "rsync://foo.bar/scap-data" cert-data-destination = "/usr/lib/cert-data" cert-data-url = "rsync://foo.bar/cert-data" report-formats-destination = "/usr/lib/report-formats" report-formats-url = "rsync://foo.bar/report-formats" scan-configs-destination = "/usr/lib/scan-configs" scan-configs-url = "rsync://foo.bar/scan-configs" port-lists-destination = "/usr/lib/port-lists" port-lists-url = "rsync://foo.bar/port-lists" openvas-lock-file = "/usr/lib/openvas.lock" gvmd-lock-file = "/usr/lib/gvmd.lock" wait-interval = 100 no-wait = true compression-level = 1 private-directory = "keep-this" verbose = 5 fail-fast = true rsync-timeout = 120 group = "foo" user = "bar" greenbone-enterprise-feed-key = "/srv/feed.key" """ path_mock = MagicMock(spec=Path) path_mock.read_text.return_value = content values = Config.load(path_mock) self.assertEqual(values["destination-prefix"], Path("/opt/lib")) self.assertEqual(values["feed-url"], "rsync://lorem.ipsum") self.assertEqual( values["gvmd-data-destination"], Path("/usr/lib/gvmd-data") ) self.assertEqual(values["gvmd-data-url"], "rsync://foo.bar/gvmd-data") self.assertEqual( values["nasl-destination"], Path("/usr/lib/openvas/plugins") ) self.assertEqual(values["notus-destination"], Path("/usr/lib/notus")) self.assertEqual(values["notus-url"], "rsync://foo.bar/notus") self.assertEqual( values["nasl-destination"], Path("/usr/lib/openvas/plugins") ) self.assertEqual(values["nasl-url"], "rsync://foo.bar/nasl") self.assertEqual( values["scap-data-destination"], Path("/usr/lib/scap-data") ) self.assertEqual(values["scap-data-url"], "rsync://foo.bar/scap-data") self.assertEqual( values["cert-data-destination"], Path("/usr/lib/cert-data") ) self.assertEqual(values["cert-data-url"], "rsync://foo.bar/cert-data") self.assertEqual( values["report-formats-destination"], Path("/usr/lib/report-formats"), ) self.assertEqual( values["report-formats-url"], "rsync://foo.bar/report-formats" ) self.assertEqual( values["scan-configs-destination"], Path("/usr/lib/scan-configs"), ) self.assertEqual( values["scan-configs-url"], "rsync://foo.bar/scan-configs" ) self.assertEqual( values["port-lists-destination"], Path("/usr/lib/port-lists"), ) self.assertEqual(values["port-lists-url"], "rsync://foo.bar/port-lists") self.assertEqual( values["openvas-lock-file"], Path("/usr/lib/openvas.lock"), ) self.assertEqual(values["gvmd-lock-file"], Path("/usr/lib/gvmd.lock")) self.assertEqual(values["wait-interval"], 100) self.assertTrue(values["no-wait"]) self.assertEqual(values["compression-level"], 1) self.assertEqual(values["private-directory"], Path("keep-this")) self.assertEqual(values["verbose"], 5) self.assertTrue(values["fail-fast"]) self.assertEqual(values["rsync-timeout"], 120) self.assertEqual(values["group"], "foo") self.assertEqual(values["user"], "bar") self.assertEqual( values["greenbone-enterprise-feed-key"], Path("/srv/feed.key") ) def test_destination_prefix(self): content = """[greenbone-feed-sync] destination-prefix = "/opt/lib/" """ path_mock = MagicMock(spec=Path) path_mock.read_text.return_value = content values = Config.load(path_mock) self.assertEqual(values["destination-prefix"], Path("/opt/lib")) self.assertEqual( values["gvmd-data-destination"], Path(f"/opt/lib/gvm/data-objects/gvmd/{DEFAULT_VERSION}"), ) self.assertEqual(values["notus-destination"], Path("/opt/lib/notus")) self.assertEqual( values["nasl-destination"], Path("/opt/lib/openvas/plugins") ) self.assertEqual( values["scap-data-destination"], Path("/opt/lib/gvm/scap-data") ) self.assertEqual( values["cert-data-destination"], Path("/opt/lib/gvm/cert-data") ) self.assertEqual( values["report-formats-destination"], Path( f"/opt/lib/gvm/data-objects/gvmd/{DEFAULT_VERSION}/report-formats" ), ) self.assertEqual( values["scan-configs-destination"], Path( f"/opt/lib/gvm/data-objects/gvmd/{DEFAULT_VERSION}/scan-configs" ), ) self.assertEqual( values["port-lists-destination"], Path( f"/opt/lib/gvm/data-objects/gvmd/{DEFAULT_VERSION}/port-lists" ), ) self.assertEqual( values["openvas-lock-file"], Path("/opt/lib/openvas/feed-update.lock"), ) self.assertEqual( values["gvmd-lock-file"], Path("/opt/lib/gvm/feed-update.lock") ) def test_feed_url(self): content = """[greenbone-feed-sync] feed-url = "rsync://foo.bar" """ path_mock = MagicMock(spec=Path) path_mock.read_text.return_value = content values = Config.load(path_mock) self.assertEqual(values["feed-url"], "rsync://foo.bar") self.assertEqual( values["gvmd-data-url"], f"rsync://foo.bar/data-feed/{DEFAULT_VERSION}/", ) self.assertEqual( values["notus-url"], f"rsync://foo.bar/vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", ) self.assertEqual( values["nasl-url"], f"rsync://foo.bar/vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/", ) self.assertEqual( values["scap-data-url"], f"rsync://foo.bar/vulnerability-feed/{DEFAULT_VERSION}/scap-data/", ) self.assertEqual( values["cert-data-url"], f"rsync://foo.bar/vulnerability-feed/{DEFAULT_VERSION}/cert-data/", ) self.assertEqual( values["report-formats-url"], f"rsync://foo.bar/data-feed/{DEFAULT_VERSION}/report-formats/", ) self.assertEqual( values["scan-configs-url"], f"rsync://foo.bar/data-feed/{DEFAULT_VERSION}/scan-configs/", ) self.assertEqual( values["port-lists-url"], f"rsync://foo.bar/data-feed/{DEFAULT_VERSION}/port-lists/", ) @patch.dict( "os.environ", { "GREENBONE_FEED_SYNC_DESTINATION_PREFIX": "/opt/lib", "GREENBONE_FEED_SYNC_URL": "rsync://lorem.ipsum", "GREENBONE_FEED_SYNC_GVMD_DATA_DESTINATION": "/usr/lib/gvmd-data", "GREENBONE_FEED_SYNC_GVMD_DATA_URL": "rsync://foo.bar/gvmd-data", "GREENBONE_FEED_SYNC_NOTUS_DESTINATION": "/usr/lib/notus", "GREENBONE_FEED_SYNC_NOTUS_URL": "rsync://foo.bar/notus", "GREENBONE_FEED_SYNC_NASL_DESTINATION": "/usr/lib/openvas/plugins/", "GREENBONE_FEED_SYNC_NASL_URL": "rsync://foo.bar/nasl", "GREENBONE_FEED_SYNC_SCAP_DATA_DESTINATION": "/usr/lib/scap-data", "GREENBONE_FEED_SYNC_SCAP_DATA_URL": "rsync://foo.bar/scap-data", "GREENBONE_FEED_SYNC_CERT_DATA_DESTINATION": "/usr/lib/cert-data", "GREENBONE_FEED_SYNC_CERT_DATA_URL": "rsync://foo.bar/cert-data", "GREENBONE_FEED_SYNC_REPORT_FORMATS_DESTINATION": "/usr/lib/report-formats", "GREENBONE_FEED_SYNC_REPORT_FORMATS_URL": "rsync://foo.bar/report-formats", "GREENBONE_FEED_SYNC_SCAN_CONFIGS_DESTINATION": "/usr/lib/scan-configs", "GREENBONE_FEED_SYNC_SCAN_CONFIGS_URL": "rsync://foo.bar/scan-configs", "GREENBONE_FEED_SYNC_PORT_LISTS_DESTINATION": "/usr/lib/port-lists", "GREENBONE_FEED_SYNC_PORT_LISTS_URL": "rsync://foo.bar/port-lists", "GREENBONE_FEED_SYNC_OPENVAS_LOCK_FILE": "/usr/lib/openvas.lock", "GREENBONE_FEED_SYNC_GVMD_LOCK_FILE": "/usr/lib/gvmd.lock", "GREENBONE_FEED_SYNC_LOCK_WAIT_INTERVAL": "100", "GREENBONE_FEED_SYNC_NO_WAIT": "1", "GREENBONE_FEED_SYNC_COMPRESSION_LEVEL": "1", "GREENBONE_FEED_SYNC_PRIVATE_DIRECTORY": "keep-this", "GREENBONE_FEED_SYNC_VERBOSE": "5", "GREENBONE_FEED_SYNC_FAIL_FAST": "1", "GREENBONE_FEED_SYNC_RSYNC_TIMEOUT": "120", "GREENBONE_FEED_SYNC_GROUP": "123", "GREENBONE_FEED_SYNC_USER": "321", "GREENBONE_FEED_SYNC_ENTERPRISE_FEED_KEY": "/tmp/some.key", }, ) def test_environment(self): values = Config.load() self.assertEqual(values["destination-prefix"], Path("/opt/lib")) self.assertEqual(values["feed-url"], "rsync://lorem.ipsum") self.assertEqual( values["gvmd-data-destination"], Path("/usr/lib/gvmd-data") ) self.assertEqual(values["gvmd-data-url"], "rsync://foo.bar/gvmd-data") self.assertEqual(values["notus-destination"], Path("/usr/lib/notus")) self.assertEqual(values["notus-url"], "rsync://foo.bar/notus") self.assertEqual( values["nasl-destination"], Path("/usr/lib/openvas/plugins") ) self.assertEqual(values["nasl-url"], "rsync://foo.bar/nasl") self.assertEqual( values["scap-data-destination"], Path("/usr/lib/scap-data") ) self.assertEqual(values["scap-data-url"], "rsync://foo.bar/scap-data") self.assertEqual( values["cert-data-destination"], Path("/usr/lib/cert-data") ) self.assertEqual(values["cert-data-url"], "rsync://foo.bar/cert-data") self.assertEqual( values["report-formats-destination"], Path("/usr/lib/report-formats"), ) self.assertEqual( values["report-formats-url"], "rsync://foo.bar/report-formats" ) self.assertEqual( values["scan-configs-destination"], Path("/usr/lib/scan-configs"), ) self.assertEqual( values["scan-configs-url"], "rsync://foo.bar/scan-configs" ) self.assertEqual( values["port-lists-destination"], Path("/usr/lib/port-lists"), ) self.assertEqual(values["port-lists-url"], "rsync://foo.bar/port-lists") self.assertEqual( values["openvas-lock-file"], Path("/usr/lib/openvas.lock"), ) self.assertEqual(values["gvmd-lock-file"], Path("/usr/lib/gvmd.lock")) self.assertEqual(values["wait-interval"], 100) self.assertTrue(values["no-wait"]) self.assertEqual(values["compression-level"], 1) self.assertEqual(values["private-directory"], Path("keep-this")) self.assertEqual(values["verbose"], 5) self.assertTrue(values["fail-fast"]) self.assertEqual(values["rsync-timeout"], 120) self.assertEqual(values["group"], 123) self.assertEqual(values["user"], 321) self.assertEqual( values["greenbone-enterprise-feed-key"], Path("/tmp/some.key") ) @patch.dict( "os.environ", { "GREENBONE_FEED_SYNC_DESTINATION_PREFIX": "/opt/lib", "GREENBONE_FEED_SYNC_URL": "rsync://lorem.ipsum", "GREENBONE_FEED_SYNC_GVMD_DATA_DESTINATION": "/usr/lib/gvmd-data", "GREENBONE_FEED_SYNC_GVMD_DATA_URL": "rsync://foo.bar/gvmd-data", "GREENBONE_FEED_SYNC_NOTUS_DESTINATION": "/usr/lib/notus", "GREENBONE_FEED_SYNC_NOTUS_URL": "rsync://foo.bar/notus", "GREENBONE_FEED_SYNC_NASL_DESTINATION": "/usr/lib/openvas/plugins/", "GREENBONE_FEED_SYNC_NASL_URL": "rsync://foo.bar/nasl", "GREENBONE_FEED_SYNC_SCAP_DATA_DESTINATION": "/usr/lib/scap-data", "GREENBONE_FEED_SYNC_SCAP_DATA_URL": "rsync://foo.bar/scap-data", "GREENBONE_FEED_SYNC_CERT_DATA_DESTINATION": "/usr/lib/cert-data", "GREENBONE_FEED_SYNC_CERT_DATA_URL": "rsync://foo.bar/cert-data", "GREENBONE_FEED_SYNC_REPORT_FORMATS_DESTINATION": "/usr/lib/report-formats", "GREENBONE_FEED_SYNC_REPORT_FORMATS_URL": "rsync://foo.bar/report-formats", "GREENBONE_FEED_SYNC_SCAN_CONFIGS_DESTINATION": "/usr/lib/scan-configs", "GREENBONE_FEED_SYNC_SCAN_CONFIGS_URL": "rsync://foo.bar/scan-configs", "GREENBONE_FEED_SYNC_PORT_LISTS_DESTINATION": "/usr/lib/port-lists", "GREENBONE_FEED_SYNC_PORT_LISTS_URL": "rsync://foo.bar/port-lists", "GREENBONE_FEED_SYNC_OPENVAS_LOCK_FILE": "/usr/lib/openvas.lock", "GREENBONE_FEED_SYNC_GVMD_LOCK_FILE": "/usr/lib/gvmd.lock", "GREENBONE_FEED_SYNC_LOCK_WAIT_INTERVAL": "100", "GREENBONE_FEED_SYNC_NO_WAIT": "1", "GREENBONE_FEED_SYNC_COMPRESSION_LEVEL": "1", "GREENBONE_FEED_SYNC_PRIVATE_DIRECTORY": "keep-this", "GREENBONE_FEED_SYNC_VERBOSE": "5", "GREENBONE_FEED_SYNC_FAIL_FAST": "1", "GREENBONE_FEED_SYNC_RSYNC_TIMEOUT": "120", "GREENBONE_FEED_SYNC_ENTERPRISE_FEED_KEY": "/tmp/some.key", }, ) def test_environment_overrides_config_file(self): content = """[greenbone-feed-sync] destination-prefix = "/svr/lib" feed-url = "rsync://ipsum.lorem" gvmd-data-destination = "/root/notus" gvmd-data-url = "rsync://bar.foo/notus" notus-destination = "/root/notus" notus-url = "rsync://bar.foo/notus" nasl-destination = "/root/openvas/plugins/" nasl-url = "rsync://bar.foo/nasl" scap-data-destination = "/root/scap-data" scap-data-url = "rsync://bar.foo/scap-data" cert-data-destination = "/root/cert-data" cert-data-url = "rsync://bar.foo/cert-data" report-formats-destination = "/root/report-formats" report-formats-url = "rsync://bar.foo/report-formats" scan-configs-destination = "/root/scan-configs" scan-configs-url = "rsync://bar.foo/scan-configs" port-lists-destination = "/root/port-lists" port-lists-url = "rsync://bar.foo/port-lists" openvas-lock-file = "/root/openvas.lock" gvmd-lock-file = "/root/gvmd.lock" wait-interval = 99 no-wait = false compression-level = 7 private-directory = "private" verbose = 99 fail-fast = false rsync-timeout = 360 greenbone-enterprise-feed-key = "/srv/feed.key" """ path_mock = MagicMock(spec=Path) path_mock.read_text.return_value = content values = Config.load(path_mock) self.assertEqual(values["destination-prefix"], Path("/opt/lib")) self.assertEqual(values["feed-url"], "rsync://lorem.ipsum") self.assertEqual( values["gvmd-data-destination"], Path("/usr/lib/gvmd-data") ) self.assertEqual(values["gvmd-data-url"], "rsync://foo.bar/gvmd-data") self.assertEqual(values["notus-destination"], Path("/usr/lib/notus")) self.assertEqual(values["notus-url"], "rsync://foo.bar/notus") self.assertEqual( values["nasl-destination"], Path("/usr/lib/openvas/plugins") ) self.assertEqual(values["nasl-url"], "rsync://foo.bar/nasl") self.assertEqual( values["scap-data-destination"], Path("/usr/lib/scap-data") ) self.assertEqual(values["scap-data-url"], "rsync://foo.bar/scap-data") self.assertEqual( values["cert-data-destination"], Path("/usr/lib/cert-data") ) self.assertEqual(values["cert-data-url"], "rsync://foo.bar/cert-data") self.assertEqual( values["report-formats-destination"], Path("/usr/lib/report-formats"), ) self.assertEqual( values["report-formats-url"], "rsync://foo.bar/report-formats" ) self.assertEqual( values["scan-configs-destination"], Path("/usr/lib/scan-configs"), ) self.assertEqual( values["scan-configs-url"], "rsync://foo.bar/scan-configs" ) self.assertEqual( values["port-lists-destination"], Path("/usr/lib/port-lists"), ) self.assertEqual(values["port-lists-url"], "rsync://foo.bar/port-lists") self.assertEqual( values["openvas-lock-file"], Path("/usr/lib/openvas.lock"), ) self.assertEqual(values["gvmd-lock-file"], Path("/usr/lib/gvmd.lock")) self.assertEqual(values["wait-interval"], 100) self.assertTrue(values["no-wait"]) self.assertEqual(values["compression-level"], 1) self.assertEqual(values["private-directory"], Path("keep-this")) self.assertEqual(values["verbose"], 5) self.assertTrue(values["fail-fast"]) self.assertEqual(values["rsync-timeout"], 120) self.assertEqual( values["greenbone-enterprise-feed-key"], Path("/tmp/some.key") ) def test_invalid_toml(self): content = "This is not TOML" path_mock = MagicMock(spec=Path) path_mock.read_text.return_value = content path_mock.absolute.return_value = "/foo/bar.toml" with self.assertRaisesRegex( ConfigFileError, "Can't load config file. /foo/bar.toml is not a valid TOML file.", ): Config.load(path_mock) def test_load_ioerror(self): with self.assertRaisesRegex( ConfigFileError, r"Can't load config file .*foo\.toml\. Error was .*", ): Config.load(Path("foo.toml")) def test_getitem(self): content = """[greenbone-feed-sync] no-wait = false compression-level = 7 private-directory = "private" """ path_mock = MagicMock(spec=Path) path_mock.read_text.return_value = content values = Config.load(path_mock) self.assertFalse(values["no-wait"]) self.assertEqual(values["compression-level"], 7) self.assertEqual(values["private-directory"], Path("private")) def test_setitem(self): config = Config() config["no-wait"] = True config["compression-level"] = 7 config["private-directory"] = "private" self.assertTrue(config["no-wait"]) self.assertEqual(config["compression-level"], 7) self.assertEqual(config["private-directory"], "private") class EnterpriseSettingsTestCase(unittest.TestCase): def test_from_key(self): content = """a_user@some.feed.server:/feed/ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor """ with temp_file(content=content, name="enterprise.key") as f: settings = EnterpriseSettings.from_key(f) self.assertEqual(settings.key, f) self.assertEqual(settings.host, "some.feed.server") self.assertEqual(settings.user, "a_user") def test_feed_url(self): key = Path("/tmp/some.key") settings = EnterpriseSettings("foo", "some.server", key) self.assertEqual( settings.feed_url(), "ssh://foo@some.server/enterprise" ) greenbone-feed-sync-24.3.0/tests/test_helper.py000066400000000000000000000170251457600213200214560ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # # pylint: disable=protected-access import errno import unittest from io import StringIO from unittest.mock import MagicMock, call, patch from pontos.testing import temp_directory from rich.console import Console from greenbone.feed.sync.errors import FileLockingError, GreenboneFeedSyncError from greenbone.feed.sync.helper import ( Spinner, change_user_and_group, flock_wait, is_root, ) class FlockTestCase(unittest.IsolatedAsyncioTestCase): async def test_locking(self): with temp_directory() as temp_dir: lock_file = temp_dir / "file.lock" self.assertFalse(lock_file.exists()) async with flock_wait(lock_file): self.assertTrue(lock_file.exists()) with self.assertRaises(FileLockingError): async with flock_wait(lock_file, wait_interval=None): pass async def test_can_not_create_parent_dirs(self): with temp_directory() as temp_dir: lock_file = temp_dir / "foo" / "file.lock" temp_dir.chmod(0) with self.assertRaisesRegex( FileLockingError, "Could not create parent directories for " ): async with flock_wait(lock_file): pass async def test_console_output(self): with temp_directory() as temp_dir: lock_file = temp_dir / "file.lock" console = MagicMock(spec=Console) async with flock_wait(lock_file, console=console): pass console.print.assert_has_calls( [ call(f"Trying to acquire lock on {lock_file.absolute()}"), call(f"Acquired lock on {lock_file.absolute()}"), call(f"Releasing lock on {lock_file.absolute()}"), ] ) @patch("greenbone.feed.sync.helper.fcntl.flock", autospec=True) async def test_retry(self, flock_mock: MagicMock): e = OSError() e.errno = errno.EACCES flock_mock.side_effect = [e, None, None] with temp_directory() as temp_dir: lock_file = temp_dir / "file.lock" console = MagicMock(spec=Console) async with flock_wait( lock_file, console=console, wait_interval=0.5, ): pass console.print.assert_has_calls( [ call(f"Trying to acquire lock on {lock_file.absolute()}"), call( f"{lock_file.absolute()} is locked by another process." " Waiting 0.5 seconds before next try." ), call(f"Trying to acquire lock on {lock_file.absolute()}"), call(f"Acquired lock on {lock_file.absolute()}"), call(f"Releasing lock on {lock_file.absolute()}"), ] ) @patch("greenbone.feed.sync.helper.fcntl.flock", autospec=True) async def test_lock_failure(self, flock_mock: MagicMock): e = OSError() e.errno = errno.EACCES flock_mock.side_effect = e with temp_directory() as temp_dir: lock_file = temp_dir / "file.lock" with self.assertRaisesRegex( FileLockingError, f"{lock_file.absolute()} is locked. Another process related " "to the feed update may already running.", ): async with flock_wait( lock_file, wait_interval=None, ): pass @patch("greenbone.feed.sync.helper.fcntl.flock", autospec=True) async def test_lock_other_failure(self, flock_mock: MagicMock): e = OSError("Other OSError") flock_mock.side_effect = e with temp_directory() as temp_dir: lock_file = temp_dir / "file.lock" with self.assertRaisesRegex(OSError, "Other OSError"): async with flock_wait( lock_file, wait_interval=None, ): pass @patch("greenbone.feed.sync.helper.fcntl.flock", autospec=True) async def test_unlock_oserror(self, flock_mock: MagicMock): flock_mock.side_effect = [None, OSError] with temp_directory() as temp_dir: lock_file = temp_dir / "file.lock" async with flock_wait( lock_file, ): pass async def test_permission_error(self): with temp_directory() as temp_dir: lock_file = temp_dir / "file.lock" lock_file.touch() lock_file.chmod(0) with self.assertRaisesRegex( FileLockingError, f"^Permission error while trying to open the lock file {lock_file.absolute()}$", ): async with flock_wait( lock_file, ): pass class SpinnerTestCase(unittest.TestCase): @patch("greenbone.feed.sync.helper.Live", autospec=True) def test_context_manager(self, live_mock: MagicMock): console = MagicMock(spec=Console) with Spinner(console, "Some Text"): pass live_mock_instance = live_mock.return_value live_mock_instance.start.assert_called_once_with() live_mock_instance.stop.assert_called_once_with() def test_render(self): out = StringIO() console = Console(file=out) with Spinner(console, "Some Text"): pass self.assertEqual("⠋ Some Text", out.getvalue()) class IsRootTestCase(unittest.TestCase): @patch("greenbone.feed.sync.helper.os.geteuid", autospec=True) def test_not_root(self, geteuid_mock: MagicMock): geteuid_mock.return_value = 123 self.assertFalse(is_root()) @patch("greenbone.feed.sync.helper.os.geteuid", autospec=True) def test_root(self, geteuid_mock: MagicMock): geteuid_mock.return_value = 0 self.assertTrue(is_root()) class ChangeUserAndGroupTestCase(unittest.TestCase): @patch("greenbone.feed.sync.helper.os", autospec=True) def test_change(self, os_mock: MagicMock): # root user should exist on all systems change_user_and_group("root", "root") os_mock.seteuid.assert_called_once_with(0) os_mock.setegid.assert_called_once_with(0) @patch("greenbone.feed.sync.helper.shutil", autospec=True) @patch("greenbone.feed.sync.helper.os", autospec=True) def test_change_with_unknown_user( self, os_mock: MagicMock, shutil_mock: MagicMock ): shutil_mock._get_uid.return_value = None with self.assertRaisesRegex( GreenboneFeedSyncError, "Can't run as user 'foo'.*" ): change_user_and_group("foo", "bar") os_mock.seteuid.assert_not_called() os_mock.setegid.assert_not_called() @patch("greenbone.feed.sync.helper.shutil", autospec=True) @patch("greenbone.feed.sync.helper.os", autospec=True) def test_change_with_unknown_group( self, os_mock: MagicMock, shutil_mock: MagicMock ): shutil_mock._get_uid.return_value = 123 shutil_mock._get_gid.return_value = None with self.assertRaisesRegex( GreenboneFeedSyncError, "Can't run as group 'bar'.*" ): change_user_and_group("foo", "bar") os_mock.seteuid.assert_not_called() os_mock.setegid.assert_not_called() greenbone-feed-sync-24.3.0/tests/test_main.py000066400000000000000000000414061457600213200211230ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import sys import unittest from pathlib import Path from unittest.mock import MagicMock, call, patch from pontos.testing import temp_directory from greenbone.feed.sync.config import DEFAULT_VERSION from greenbone.feed.sync.errors import GreenboneFeedSyncError, RsyncError from greenbone.feed.sync.main import ( Sync, do_selftest, feed_sync, filter_syncs, main, ) class FilterSyncsTestCase(unittest.TestCase): def test_filter_syncs(self): sync_a = Sync(name="a", types=["foo", "bar"], url="a", destination="a") sync_b = Sync(name="b", types=["foo", "baz"], url="b", destination="b") sync_c = Sync(name="c", types=["bar", "baz"], url="c", destination="c") sync_list = filter_syncs( "file.lock", "foo", sync_a, sync_b, sync_c, ) self.assertEqual(len(sync_list.syncs), 2) self.assertEqual(sync_list.lock_file, "file.lock") self.assertEqual(sync_list.syncs[0], sync_a) self.assertEqual(sync_list.syncs[1], sync_b) class DoSelftestTestCase(unittest.TestCase): @patch("greenbone.feed.sync.main.subprocess.run") def test_do_selftest_success(self, mock_subprocess_run: MagicMock): mock_subprocess_run.side_effect = [""] do_selftest() @patch("greenbone.feed.sync.main.subprocess.run") def test_do_selftest_rsync_fail(self, mock_subprocess_run: MagicMock): mock_subprocess_run.side_effect = [PermissionError] with self.assertRaisesRegex( GreenboneFeedSyncError, "The rsync binary could not be found." ): do_selftest() class FeedSyncTestCase(unittest.IsolatedAsyncioTestCase): @patch("greenbone.feed.sync.main.Rsync", autospec=True) @patch("greenbone.feed.sync.main.change_user_and_group", autospec=True) @patch("greenbone.feed.sync.main.is_root", autospec=True) async def test_do_not_run_as_root( self, is_root_mock: MagicMock, change_user_mock: MagicMock, rsync_mock: MagicMock, ): is_root_mock.return_value = True console = MagicMock() rsync_mock_instance = rsync_mock.return_value with ( temp_directory() as temp_dir, patch.dict( "os.environ", {"GREENBONE_FEED_SYNC_DESTINATION_PREFIX": str(temp_dir)}, ), patch.object( sys, "argv", [ "greenbone-feed-sync", "--type", "nvt", ], ), ): ret = await feed_sync(console=console, error_console=console) self.assertEqual(ret, 0) change_user_mock.assert_called_once_with("gvm", "gvm") rsync_mock.assert_called_once_with( private_subdir=None, verbose=False, compression_level=9, ssh_key=Path("/etc/gvm/greenbone-enterprise-feed-key"), ) console.print.assert_has_calls( [ call( "Trying to acquire lock on " f"{temp_dir}/openvas/feed-update.lock" ), call(f"Acquired lock on {temp_dir}/openvas/feed-update.lock"), call(f"Releasing lock on {temp_dir}/openvas/feed-update.lock"), call(), ] ) rsync_mock_instance.sync.assert_has_awaits( [ call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", destination=temp_dir / "notus", ), call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/", destination=temp_dir / "openvas/plugins", ), ] ) @patch("greenbone.feed.sync.main.Rsync", autospec=True) async def test_sync_nvts(self, rsync_mock: MagicMock): console = MagicMock() rsync_mock_instance = rsync_mock.return_value with ( temp_directory() as temp_dir, patch.dict( "os.environ", {"GREENBONE_FEED_SYNC_DESTINATION_PREFIX": str(temp_dir)}, ), patch.object( sys, "argv", [ "greenbone-feed-sync", "--type", "nvt", ], ), ): ret = await feed_sync(console=console, error_console=console) self.assertEqual(ret, 0) rsync_mock.assert_called_once_with( private_subdir=None, verbose=False, compression_level=9, ssh_key=Path("/etc/gvm/greenbone-enterprise-feed-key"), ) console.print.assert_has_calls( [ call( "Trying to acquire lock on " f"{temp_dir}/openvas/feed-update.lock" ), call( f"Acquired lock on {temp_dir}/openvas/feed-update.lock" ), call( f"Releasing lock on {temp_dir}/openvas/feed-update.lock" ), call(), ] ) rsync_mock_instance.sync.assert_has_awaits( [ call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", destination=temp_dir / "notus", ), call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/", destination=temp_dir / "openvas/plugins", ), ] ) @patch("greenbone.feed.sync.main.Rsync", autospec=True) async def test_sync_nvts_verbose(self, rsync_mock: MagicMock): console = MagicMock() rsync_mock_instance = rsync_mock.return_value with ( temp_directory() as temp_dir, patch.dict( "os.environ", {"GREENBONE_FEED_SYNC_DESTINATION_PREFIX": str(temp_dir)}, ), patch.object( sys, "argv", ["greenbone-feed-sync", "--type", "nvt", "-vvv"], ), ): ret = await feed_sync(console=console, error_console=console) self.assertEqual(ret, 0) rsync_mock.assert_called_once_with( private_subdir=None, verbose=True, compression_level=9, ssh_key=Path("/etc/gvm/greenbone-enterprise-feed-key"), ) console.print.assert_has_calls( [ call( "Trying to acquire lock on " f"{temp_dir}/openvas/feed-update.lock" ), call( f"Acquired lock on {temp_dir}/openvas/feed-update.lock" ), call( "Downloading Notus files from " "rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/ " f"to {temp_dir}/notus" ), call(), call( "Downloading NASL files from " "rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/ " f"to {temp_dir}/openvas/plugins" ), call(), call( f"Releasing lock on {temp_dir}/openvas/feed-update.lock" ), call(), ] ) rsync_mock_instance.sync.assert_has_awaits( [ call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", destination=temp_dir / "notus", ), call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/", destination=temp_dir / "openvas/plugins", ), ] ) @patch("greenbone.feed.sync.main.Rsync", autospec=True) async def test_sync_nvts_quiet(self, rsync_mock: MagicMock): console = MagicMock() rsync_mock_instance = rsync_mock.return_value with ( temp_directory() as temp_dir, patch.dict( "os.environ", {"GREENBONE_FEED_SYNC_DESTINATION_PREFIX": str(temp_dir)}, ), patch.object( sys, "argv", ["greenbone-feed-sync", "--type", "nvt", "--quiet"], ), ): ret = await feed_sync(console=console, error_console=console) self.assertEqual(ret, 0) rsync_mock.assert_called_once_with( private_subdir=None, verbose=False, compression_level=9, ssh_key=Path("/etc/gvm/greenbone-enterprise-feed-key"), ) console.print.assert_not_called() rsync_mock_instance.sync.assert_has_awaits( [ call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", destination=temp_dir / "notus", ), call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/", destination=temp_dir / "openvas/plugins", ), ] ) @patch("greenbone.feed.sync.main.Rsync", autospec=True) async def test_sync_nvts_rsync_error(self, rsync_mock: MagicMock): console = MagicMock() rsync_mock_instance = rsync_mock.return_value rsync_mock_instance.sync.side_effect = RsyncError( 2, [], b"An rsync error" ) with ( temp_directory() as temp_dir, patch.dict( "os.environ", {"GREENBONE_FEED_SYNC_DESTINATION_PREFIX": str(temp_dir)}, ), patch.object( sys, "argv", ["greenbone-feed-sync", "--type", "nvt", "--fail-fast"], ), ): ret = await feed_sync(console=console, error_console=console) self.assertEqual(ret, 1) rsync_mock.assert_called_once_with( private_subdir=None, verbose=False, compression_level=9, ssh_key=Path("/etc/gvm/greenbone-enterprise-feed-key"), ) console.print.assert_has_calls( [ call( "Trying to acquire lock on " f"{temp_dir}/openvas/feed-update.lock" ), call( f"Acquired lock on {temp_dir}/openvas/feed-update.lock" ), call("An rsync error"), call( f"Releasing lock on {temp_dir}/openvas/feed-update.lock" ), ] ) rsync_mock_instance.sync.assert_has_awaits( [ call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", destination=temp_dir / "notus", ), ] ) class MainFunctionTestCase(unittest.TestCase): @patch("greenbone.feed.sync.main.Console") @patch("greenbone.feed.sync.main.Rsync", autospec=True) def test_sync_nvts(self, rsync_mock: MagicMock, console_mock: MagicMock): rsync_mock_instance = rsync_mock.return_value console_mock_instance = console_mock.return_value with ( temp_directory() as temp_dir, patch.dict( "os.environ", {"GREENBONE_FEED_SYNC_DESTINATION_PREFIX": str(temp_dir)}, ), patch.object( sys, "argv", [ "greenbone-feed-sync", "--type", "nvt", ], ), ): with self.assertRaises(SystemExit) as cm: main() self.assertEqual(cm.exception.code, 0) rsync_mock.assert_called_once_with( private_subdir=None, verbose=False, compression_level=9, ssh_key=Path("/etc/gvm/greenbone-enterprise-feed-key"), ) console_mock_instance.print.assert_has_calls( [ call( "Trying to acquire lock on " f"{temp_dir}/openvas/feed-update.lock" ), call( f"Acquired lock on {temp_dir}/openvas/feed-update.lock" ), call( f"Releasing lock on {temp_dir}/openvas/feed-update.lock" ), call(), ] ) rsync_mock_instance.sync.assert_has_awaits( [ call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", destination=temp_dir / "notus", ), call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/", destination=temp_dir / "openvas/plugins", ), ] ) @patch("greenbone.feed.sync.main.Console") @patch("greenbone.feed.sync.main.Rsync", autospec=True) def test_sync_nvts_error( self, rsync_mock: MagicMock, console_mock: MagicMock ): rsync_mock_instance = rsync_mock.return_value console_mock_instance = console_mock.return_value rsync_mock_instance.sync.side_effect = GreenboneFeedSyncError( "An error" ) with ( temp_directory() as temp_dir, patch.dict( "os.environ", {"GREENBONE_FEED_SYNC_DESTINATION_PREFIX": str(temp_dir)}, ), patch.object( sys, "argv", ["greenbone-feed-sync", "--type", "nvt", "--fail-fast"], ), ): with self.assertRaises(SystemExit) as cm: main() self.assertEqual(cm.exception.code, 1) rsync_mock.assert_called_once_with( private_subdir=None, verbose=False, compression_level=9, ssh_key=Path("/etc/gvm/greenbone-enterprise-feed-key"), ) console_mock_instance.print.assert_has_calls( [ call( "Trying to acquire lock on " f"{temp_dir}/openvas/feed-update.lock" ), call( f"Acquired lock on {temp_dir}/openvas/feed-update.lock" ), call( f"Releasing lock on {temp_dir}/openvas/feed-update.lock" ), call("[red]❌[/red]Error: An error"), ] ) rsync_mock_instance.sync.assert_has_awaits( [ call( url="rsync://feed.community.greenbone.net/community/" f"vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", destination=temp_dir / "notus", ), ] ) greenbone-feed-sync-24.3.0/tests/test_parser.py000066400000000000000000000760201457600213200214730ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # # pylint: disable=line-too-long, too-many-lines import io import sys import unittest from contextlib import redirect_stderr, redirect_stdout from pathlib import Path from unittest.mock import MagicMock, patch from pontos.testing import temp_file from greenbone.feed.sync.config import ( DEFAULT_CERT_DATA_PATH, DEFAULT_CERT_DATA_URL_PATH, DEFAULT_CONFIG_FILE, DEFAULT_DESTINATION_PREFIX, DEFAULT_ENTERPRISE_KEY_PATH, DEFAULT_GVMD_DATA_PATH, DEFAULT_GVMD_DATA_URL_PATH, DEFAULT_GVMD_LOCK_FILE_PATH, DEFAULT_NASL_PATH, DEFAULT_NASL_URL_PATH, DEFAULT_NOTUS_PATH, DEFAULT_NOTUS_URL_PATH, DEFAULT_OPENVAS_LOCK_FILE_PATH, DEFAULT_PORT_LISTS_PATH, DEFAULT_PORT_LISTS_URL_PATH, DEFAULT_REPORT_FORMATS_PATH, DEFAULT_REPORT_FORMATS_URL_PATH, DEFAULT_SCAN_CONFIGS_PATH, DEFAULT_SCAN_CONFIGS_URL_PATH, DEFAULT_SCAP_DATA_PATH, DEFAULT_SCAP_DATA_URL_PATH, DEFAULT_USER_CONFIG_FILE, DEFAULT_VERSION, ) from greenbone.feed.sync.errors import ConfigFileError from greenbone.feed.sync.helper import DEFAULT_FLOCK_WAIT_INTERVAL from greenbone.feed.sync.parser import CliParser, feed_type from greenbone.feed.sync.rsync import ( DEFAULT_RSYNC_COMPRESSION_LEVEL, DEFAULT_RSYNC_URL, ) class FeedTypeTestCase(unittest.TestCase): def test_nvt(self): self.assertEqual("nvt", feed_type("nvt")) self.assertEqual("nvt", feed_type("nvts")) self.assertEqual("nvt", feed_type("NVT")) self.assertEqual("nvt", feed_type("NVTS")) def test_report_format(self): self.assertEqual("report-format", feed_type("report-format")) self.assertEqual("report-format", feed_type("report-formats")) self.assertEqual("report-format", feed_type("report_format")) self.assertEqual("report-format", feed_type("report_formats")) self.assertEqual("report-format", feed_type("REPORT_FORMAT")) self.assertEqual("report-format", feed_type("REPORT_FORMATS")) self.assertEqual("report-format", feed_type("REPORT-FORMAT")) self.assertEqual("report-format", feed_type("REPORT-FORMATS")) def test_port_list(self): self.assertEqual("port-list", feed_type("port-list")) self.assertEqual("port-list", feed_type("port-lists")) self.assertEqual("port-list", feed_type("port_list")) self.assertEqual("port-list", feed_type("port_lists")) self.assertEqual("port-list", feed_type("PORT_LIST")) self.assertEqual("port-list", feed_type("PORT_LISTS")) self.assertEqual("port-list", feed_type("PORT-LIST")) self.assertEqual("port-list", feed_type("PORT-LISTS")) def test_scan_config(self): self.assertEqual("scan-config", feed_type("scan-config")) self.assertEqual("scan-config", feed_type("scan-configs")) self.assertEqual("scan-config", feed_type("scan_config")) self.assertEqual("scan-config", feed_type("scan_configs")) self.assertEqual("scan-config", feed_type("SCAN_CONFIG")) self.assertEqual("scan-config", feed_type("SCAN_CONFIGS")) self.assertEqual("scan-config", feed_type("SCAN-CONFIG")) self.assertEqual("scan-config", feed_type("SCAN-CONFIGS")) def test_gvmd_data(self): self.assertEqual("gvmd-data", feed_type("gvmd-data")) self.assertEqual("gvmd-data", feed_type("gvmd_data")) self.assertEqual("gvmd-data", feed_type("GVMD-DATA")) self.assertEqual("gvmd-data", feed_type("GVMD_DATA")) class CliParserTestCase(unittest.TestCase): def test_output_group(self): parser = CliParser() with redirect_stderr(io.StringIO()) as f, self.assertRaises(SystemExit): parser.parse_arguments(["-vvv", "--quiet"]) self.assertIn( "argument --quiet: not allowed with argument --verbose/-v", f.getvalue(), ) def test_wait_group(self): parser = CliParser() with redirect_stderr(io.StringIO()) as f, self.assertRaises(SystemExit): parser.parse_arguments(["--no-wait", "--wait-interval", "20"]) self.assertIn( "argument --wait-interval: not allowed with argument --no-wait", f.getvalue(), ) def test_defaults(self): parser = CliParser() args = parser.parse_arguments([]) self.assertEqual(args.type, "all") self.assertEqual( args.destination_prefix, Path(DEFAULT_DESTINATION_PREFIX) ) self.assertEqual(args.feed_url, DEFAULT_RSYNC_URL) self.assertEqual( args.gvmd_data_destination, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_GVMD_DATA_PATH, ) self.assertEqual( args.gvmd_data_url, f"{DEFAULT_RSYNC_URL}{DEFAULT_GVMD_DATA_URL_PATH}", ) self.assertEqual( args.notus_destination, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_NOTUS_PATH, ) self.assertEqual( args.notus_url, f"{DEFAULT_RSYNC_URL}{DEFAULT_NOTUS_URL_PATH}" ) self.assertEqual( args.nasl_destination, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_NASL_PATH, ) self.assertEqual( args.nasl_url, f"{DEFAULT_RSYNC_URL}{DEFAULT_NASL_URL_PATH}" ) self.assertEqual( args.scap_data_destination, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_SCAP_DATA_PATH, ) self.assertEqual( args.scap_data_url, f"{DEFAULT_RSYNC_URL}{DEFAULT_SCAP_DATA_URL_PATH}", ) self.assertEqual( args.cert_data_destination, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_CERT_DATA_PATH, ) self.assertEqual( args.cert_data_url, f"{DEFAULT_RSYNC_URL}{DEFAULT_CERT_DATA_URL_PATH}", ) self.assertEqual( args.report_formats_destination, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_REPORT_FORMATS_PATH, ) self.assertEqual( args.report_formats_url, f"{DEFAULT_RSYNC_URL}{DEFAULT_REPORT_FORMATS_URL_PATH}", ) self.assertEqual( args.scan_configs_destination, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_SCAN_CONFIGS_PATH, ) self.assertEqual( args.scan_configs_url, f"{DEFAULT_RSYNC_URL}{DEFAULT_SCAN_CONFIGS_URL_PATH}", ) self.assertEqual( args.port_lists_destination, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_PORT_LISTS_PATH, ) self.assertEqual( args.port_lists_url, f"{DEFAULT_RSYNC_URL}{DEFAULT_PORT_LISTS_URL_PATH}", ) self.assertEqual( args.gvmd_lock_file, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_GVMD_LOCK_FILE_PATH, ) self.assertEqual( args.openvas_lock_file, Path(DEFAULT_DESTINATION_PREFIX) / DEFAULT_OPENVAS_LOCK_FILE_PATH, ) self.assertEqual(args.wait_interval, DEFAULT_FLOCK_WAIT_INTERVAL) self.assertFalse(args.no_wait) self.assertEqual( args.compression_level, DEFAULT_RSYNC_COMPRESSION_LEVEL ) self.assertIsNone(args.private_directory) self.assertIsNone(args.verbose) self.assertFalse(args.fail_fast) self.assertIsNone(args.rsync_timeout) self.assertEqual( args.greenbone_enterprise_feed_key, Path(DEFAULT_ENTERPRISE_KEY_PATH), ) def test_help(self): parser = CliParser() with ( redirect_stdout(io.StringIO()) as f, self.assertRaises(SystemExit) as cm, ): parser.parse_arguments(["--help"]) self.assertEqual(cm.exception.code, 0) self.assertTrue(f.getvalue().startswith("usage: ")) def test_verbose(self): parser = CliParser() args = parser.parse_arguments(["-v"]) self.assertEqual(args.verbose, 1) args = parser.parse_arguments(["--verbose"]) self.assertEqual(args.verbose, 1) args = parser.parse_arguments(["-vv"]) self.assertEqual(args.verbose, 2) args = parser.parse_arguments(["-vvv"]) self.assertEqual(args.verbose, 3) args = parser.parse_arguments(["-vvvv"]) self.assertEqual(args.verbose, 4) def test_quiet(self): parser = CliParser() args = parser.parse_arguments(["--quiet"]) self.assertTrue(args.quiet) def test_selftest(self): parser = CliParser() args = parser.parse_arguments(["--selftest"]) self.assertTrue(args.selftest) @patch("greenbone.feed.sync.parser.Path") def test_use_default_config_files(self, path_mock): path_mock_instance = path_mock.return_value path_mock_instance.expanduser.return_value = path_mock_instance path_mock_instance.resolve.return_value = path_mock_instance path_mock_instance.exists.return_value = False parser = CliParser() parser.parse_arguments([]) path_mock.assert_any_call(DEFAULT_USER_CONFIG_FILE) path_mock.assert_any_call(DEFAULT_CONFIG_FILE) def test_private_directory(self): parser = CliParser() args = parser.parse_arguments(["--private-directory", "foobar"]) self.assertEqual(args.private_directory, Path("foobar")) def test_compression_level(self): parser = CliParser() args = parser.parse_arguments(["--compression-level", "0"]) self.assertEqual(args.compression_level, 0) args = parser.parse_arguments(["--compression-level", "1"]) self.assertEqual(args.compression_level, 1) args = parser.parse_arguments(["--compression-level", "2"]) self.assertEqual(args.compression_level, 2) args = parser.parse_arguments(["--compression-level", "3"]) self.assertEqual(args.compression_level, 3) args = parser.parse_arguments(["--compression-level", "4"]) self.assertEqual(args.compression_level, 4) args = parser.parse_arguments(["--compression-level", "5"]) self.assertEqual(args.compression_level, 5) args = parser.parse_arguments(["--compression-level", "6"]) self.assertEqual(args.compression_level, 6) args = parser.parse_arguments(["--compression-level", "7"]) self.assertEqual(args.compression_level, 7) args = parser.parse_arguments(["--compression-level", "8"]) self.assertEqual(args.compression_level, 8) args = parser.parse_arguments(["--compression-level", "9"]) self.assertEqual(args.compression_level, 9) with redirect_stderr(io.StringIO()) as f, self.assertRaises(SystemExit): parser.parse_arguments(["--compression-level", "10"]) self.assertIn( "error: argument --compression-level: invalid choice: 10 " "(choose from 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)", f.getvalue(), ) def test_gvmd_data_destination(self): parser = CliParser() args = parser.parse_arguments(["--gvmd-data-destination", "foo/bar"]) self.assertEqual(args.gvmd_data_destination, Path("foo/bar")) def test_gvmd_data_url(self): parser = CliParser() args = parser.parse_arguments( ["--gvmd-data-url", "rsync://foo.bar/gvmd-data"] ) self.assertEqual(args.gvmd_data_url, "rsync://foo.bar/gvmd-data") def test_notus_destination(self): parser = CliParser() args = parser.parse_arguments(["--notus-destination", "foo/bar"]) self.assertEqual(args.notus_destination, Path("foo/bar")) def test_notus_url(self): parser = CliParser() args = parser.parse_arguments(["--notus-url", "rsync://foo.bar/notus"]) self.assertEqual(args.notus_url, "rsync://foo.bar/notus") def test_nasl_destination(self): parser = CliParser() args = parser.parse_arguments(["--nasl-destination", "foo/bar"]) self.assertEqual(args.nasl_destination, Path("foo/bar")) def test_nasl_url(self): parser = CliParser() args = parser.parse_arguments(["--nasl-url", "rsync://foo.bar/nasl"]) self.assertEqual(args.nasl_url, "rsync://foo.bar/nasl") def test_scap_data_destination(self): parser = CliParser() args = parser.parse_arguments(["--scap-data-destination", "foo/bar"]) self.assertEqual(args.scap_data_destination, Path("foo/bar")) def test_scap_data_url(self): parser = CliParser() args = parser.parse_arguments( ["--scap-data-url", "rsync://foo.bar/scap-data"] ) self.assertEqual(args.scap_data_url, "rsync://foo.bar/scap-data") def test_cert_data_destination(self): parser = CliParser() args = parser.parse_arguments(["--cert-data-destination", "foo/bar"]) self.assertEqual(args.cert_data_destination, Path("foo/bar")) def test_cert_data_url(self): parser = CliParser() args = parser.parse_arguments( ["--cert-data-url", "rsync://foo.bar/cert-data"] ) self.assertEqual(args.cert_data_url, "rsync://foo.bar/cert-data") def test_report_formats_destination(self): parser = CliParser() args = parser.parse_arguments( ["--report-formats-destination", "foo/bar"] ) self.assertEqual(args.report_formats_destination, Path("foo/bar")) def test_report_formats_url(self): parser = CliParser() args = parser.parse_arguments( ["--report-formats-url", "rsync://foo.bar/report-formats"] ) self.assertEqual( args.report_formats_url, "rsync://foo.bar/report-formats" ) def test_scan_configs_destination(self): parser = CliParser() args = parser.parse_arguments(["--scan-configs-destination", "foo/bar"]) self.assertEqual(args.scan_configs_destination, Path("foo/bar")) def test_scan_configs_url(self): parser = CliParser() args = parser.parse_arguments( ["--scan-configs-url", "rsync://foo.bar/scan-configs"] ) self.assertEqual(args.scan_configs_url, "rsync://foo.bar/scan-configs") def test_port_lists_destination(self): parser = CliParser() args = parser.parse_arguments(["--port-lists-destination", "foo/bar"]) self.assertEqual(args.port_lists_destination, Path("foo/bar")) def test_port_lists_url(self): parser = CliParser() args = parser.parse_arguments( ["--port-lists-url", "rsync://foo.bar/port-lists"] ) self.assertEqual(args.port_lists_url, "rsync://foo.bar/port-lists") def test_gvmd_lock_file(self): parser = CliParser() args = parser.parse_arguments(["--gvmd-lock-file", "/run/gvmd.lock"]) self.assertEqual(args.gvmd_lock_file, Path("/run/gvmd.lock")) def test_openvas_lock_file(self): parser = CliParser() args = parser.parse_arguments( ["--openvas-lock-file", "/run/openvas.lock"] ) self.assertEqual(args.openvas_lock_file, Path("/run/openvas.lock")) def test_fail_fast(self): parser = CliParser() args = parser.parse_arguments(["--fail-fast"]) self.assertTrue(args.fail_fast) args = parser.parse_arguments(["--failfast"]) self.assertTrue(args.fail_fast) def test_no_wait(self): parser = CliParser() args = parser.parse_arguments(["--no-wait"]) self.assertTrue(args.no_wait) def test_wait_interval(self): parser = CliParser() args = parser.parse_arguments(["--wait-interval", "100"]) self.assertEqual(args.wait_interval, 100) def test_rsync_timeout(self): parser = CliParser() args = parser.parse_arguments(["--rsync-timeout", "120"]) self.assertEqual(args.rsync_timeout, 120) def test_greenbone_enterprise_feed_key(self): parser = CliParser() args = parser.parse_arguments( ["--greenbone-enterprise-feed-key", "/tmp/some.key"] ) self.assertEqual( args.greenbone_enterprise_feed_key, Path("/tmp/some.key") ) def test_other(self): parser = CliParser() with ( redirect_stderr(io.StringIO()) as f, self.assertRaises(SystemExit) as cm, ): parser.parse_arguments(["--foo-bar", "10"]) self.assertIn("error: unrecognized arguments: --foo-bar", f.getvalue()) self.assertEqual(cm.exception.code, 2) @patch("greenbone.feed.sync.parser.Path") def test_config(self, path_mock: MagicMock): content = """[greenbone-feed-sync] verbose = 3 feed-url = "rsync://foo.bar" destination-prefix = "/usr/lib" """ path_mock_instance = path_mock.return_value path_mock_instance.absolute.return_value = "/foo/bar/foo.toml" path_mock_instance.expanduser.return_value = path_mock_instance path_mock_instance.resolve.return_value = path_mock_instance path_mock_instance.exists.return_value = True path_mock_instance.read_text.return_value = content parser = CliParser() args = parser.parse_arguments(["--config", "foo.toml"]) self.assertEqual(args.verbose, 3) self.assertEqual(args.feed_url, "rsync://foo.bar") self.assertEqual(args.destination_prefix, Path("/usr/lib")) @patch("greenbone.feed.sync.parser.Path") def test_load_from_default_config(self, path_mock: MagicMock): content = """[greenbone-feed-sync] verbose = 3 feed-url = "rsync://foo.bar" destination-prefix = "/usr/lib" """ path_mock_instance = path_mock.return_value path_mock_instance.absolute.return_value = ( "/foo/bar/.config/greenbone-feed-sync.toml" ) path_mock_instance.expanduser.return_value = path_mock_instance path_mock_instance.resolve.return_value = path_mock_instance path_mock_instance.exists.return_value = True path_mock_instance.read_text.return_value = content parser = CliParser() args = parser.parse_arguments([]) self.assertEqual(args.verbose, 3) self.assertEqual(args.feed_url, "rsync://foo.bar") self.assertEqual(args.destination_prefix, Path("/usr/lib")) @patch.dict( "os.environ", { "GREENBONE_FEED_SYNC_DESTINATION_PREFIX": "/usr/lib", "GREENBONE_FEED_SYNC_URL": "rsync://foo.bar", "GREENBONE_FEED_SYNC_VERBOSE": "3", }, ) def test_from_environment(self): parser = CliParser() args = parser.parse_arguments([]) self.assertEqual(args.verbose, 3) self.assertEqual(args.feed_url, "rsync://foo.bar") self.assertEqual(args.destination_prefix, Path("/usr/lib")) @patch.dict( "os.environ", { "GREENBONE_FEED_SYNC_DESTINATION_PREFIX": "/usr/lib", "GREENBONE_FEED_SYNC_URL": "rsync://foo.bar", "GREENBONE_FEED_SYNC_VERBOSE": "3", }, ) @patch("greenbone.feed.sync.parser.Path") def test_environment_takes_precedence(self, path_mock): content = """[greenbone-feed-sync] verbose = 9 feed-url = "rsync://lorem.ipsum" destination-prefix = "/opt/lib" wait-interval = 100 """ path_mock_instance = path_mock.return_value path_mock_instance.absolute.return_value = ( "/foo/bar/.config/greenbone-feed-sync.toml" ) path_mock_instance.expanduser.return_value = path_mock_instance path_mock_instance.resolve.return_value = path_mock_instance path_mock_instance.exists.return_value = True path_mock_instance.read_text.return_value = content parser = CliParser() args = parser.parse_arguments([]) self.assertEqual(args.verbose, 3) self.assertEqual(args.feed_url, "rsync://foo.bar") self.assertEqual(args.destination_prefix, Path("/usr/lib")) self.assertEqual(args.wait_interval, 100) @patch.dict( "os.environ", { "GREENBONE_FEED_SYNC_DESTINATION_PREFIX": "/usr/lib", "GREENBONE_FEED_SYNC_URL": "rsync://foo.bar", "GREENBONE_FEED_SYNC_VERBOSE": "3", }, ) @patch("greenbone.feed.sync.parser.Path") def test_argument_takes_precedence(self, path_mock): content = """[greenbone-feed-sync] verbose = 9 feed-url = "rsync://lorem.ipsum" destination-prefix = "/opt/lib" wait-interval = 100 """ path_mock_instance = path_mock.return_value path_mock_instance.absolute.return_value = ( "/foo/bar/.config/greenbone-feed-sync.toml" ) path_mock_instance.expanduser.return_value = path_mock_instance path_mock_instance.resolve.return_value = path_mock_instance path_mock_instance.exists.return_value = True path_mock_instance.read_text.return_value = content parser = CliParser() args = parser.parse_arguments( [ "--wait-interval", "90", ] ) self.assertEqual(args.verbose, 3) self.assertEqual(args.feed_url, "rsync://foo.bar") self.assertEqual(args.destination_prefix, Path("/usr/lib")) self.assertEqual(args.wait_interval, 90) def test_config_file_not_exists(self): parser = CliParser() with self.assertRaisesRegex( ConfigFileError, "Config file foo.bar does not exist." ): parser.parse_arguments(["--config", "foo.bar"]) def test_type(self): parser = CliParser() args = parser.parse_arguments(["--type", "nvt"]) self.assertEqual(args.type, "nvt") args = parser.parse_arguments(["--type", "nvts"]) self.assertEqual(args.type, "nvt") args = parser.parse_arguments(["--type", "NVT"]) self.assertEqual(args.type, "nvt") args = parser.parse_arguments(["--type", "NVTS"]) self.assertEqual(args.type, "nvt") args = parser.parse_arguments(["--type", "notus"]) self.assertEqual(args.type, "notus") args = parser.parse_arguments(["--type", "NOTUS"]) self.assertEqual(args.type, "notus") args = parser.parse_arguments(["--type", "NoTuS"]) self.assertEqual(args.type, "notus") args = parser.parse_arguments(["--type", "nasl"]) self.assertEqual(args.type, "nasl") args = parser.parse_arguments(["--type", "NASL"]) self.assertEqual(args.type, "nasl") args = parser.parse_arguments(["--type", "NaSl"]) self.assertEqual(args.type, "nasl") args = parser.parse_arguments(["--type", "scap"]) self.assertEqual(args.type, "scap") args = parser.parse_arguments(["--type", "SCAP"]) self.assertEqual(args.type, "scap") args = parser.parse_arguments(["--type", "ScAp"]) self.assertEqual(args.type, "scap") args = parser.parse_arguments(["--type", "cert"]) self.assertEqual(args.type, "cert") args = parser.parse_arguments(["--type", "CERT"]) self.assertEqual(args.type, "cert") args = parser.parse_arguments(["--type", "CeRt"]) self.assertEqual(args.type, "cert") args = parser.parse_arguments(["--type", "all"]) self.assertEqual(args.type, "all") args = parser.parse_arguments(["--type", "ALL"]) self.assertEqual(args.type, "all") args = parser.parse_arguments(["--type", "AlL"]) self.assertEqual(args.type, "all") args = parser.parse_arguments(["--type", "report-format"]) self.assertEqual(args.type, "report-format") args = parser.parse_arguments(["--type", "REPORT-FORMAT"]) self.assertEqual(args.type, "report-format") args = parser.parse_arguments(["--type", "report_format"]) self.assertEqual(args.type, "report-format") args = parser.parse_arguments(["--type", "REPORT_FORMAT"]) self.assertEqual(args.type, "report-format") args = parser.parse_arguments(["--type", "Report-Format"]) self.assertEqual(args.type, "report-format") args = parser.parse_arguments(["--type", "report-formats"]) self.assertEqual(args.type, "report-format") args = parser.parse_arguments(["--type", "REPORT_FORMATS"]) self.assertEqual(args.type, "report-format") args = parser.parse_arguments(["--type", "scan-config"]) self.assertEqual(args.type, "scan-config") args = parser.parse_arguments(["--type", "SCAN-CONFIG"]) self.assertEqual(args.type, "scan-config") args = parser.parse_arguments(["--type", "scan_config"]) self.assertEqual(args.type, "scan-config") args = parser.parse_arguments(["--type", "SCAN_config"]) self.assertEqual(args.type, "scan-config") args = parser.parse_arguments(["--type", "Scan-Config"]) self.assertEqual(args.type, "scan-config") args = parser.parse_arguments(["--type", "scan-configs"]) self.assertEqual(args.type, "scan-config") args = parser.parse_arguments(["--type", "SCAN_CONFIGS"]) self.assertEqual(args.type, "scan-config") args = parser.parse_arguments(["--type", "port-list"]) self.assertEqual(args.type, "port-list") args = parser.parse_arguments(["--type", "PORT-LIST"]) self.assertEqual(args.type, "port-list") args = parser.parse_arguments(["--type", "port_list"]) self.assertEqual(args.type, "port-list") args = parser.parse_arguments(["--type", "PORT_LIST"]) self.assertEqual(args.type, "port-list") args = parser.parse_arguments(["--type", "port-list"]) self.assertEqual(args.type, "port-list") args = parser.parse_arguments(["--type", "port-lists"]) self.assertEqual(args.type, "port-list") args = parser.parse_arguments(["--type", "PORT_LISTS"]) self.assertEqual(args.type, "port-list") args = parser.parse_arguments(["--type", "gvmd-data"]) self.assertEqual(args.type, "gvmd-data") args = parser.parse_arguments(["--type", "GVMD-DATA"]) self.assertEqual(args.type, "gvmd-data") args = parser.parse_arguments(["--type", "gvmd_data"]) self.assertEqual(args.type, "gvmd-data") args = parser.parse_arguments(["--type", "GVMD_DATA"]) self.assertEqual(args.type, "gvmd-data") args = parser.parse_arguments(["--type", "gvmd-data"]) self.assertEqual(args.type, "gvmd-data") def test_group(self): parser = CliParser() args = parser.parse_arguments(["--group", "some_group"]) self.assertEqual(args.group, "some_group") args = parser.parse_arguments(["--group", "123"]) self.assertEqual(args.group, 123) def test_user(self): parser = CliParser() args = parser.parse_arguments(["--user", "some_user"]) self.assertEqual(args.user, "some_user") args = parser.parse_arguments(["--user", "123"]) self.assertEqual(args.user, 123) def test_feed_url_from_enterprise_feed_key(self): parser = CliParser() content = """a_user@some.feed.server:/feed/ Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor """ with temp_file(content=content, name="enterprise.key") as f: args = parser.parse_arguments( ["--greenbone-enterprise-feed-key", str(f)] ) self.assertEqual( args.feed_url, "ssh://a_user@some.feed.server/enterprise" ) self.assertEqual( args.gvmd_data_url, f"ssh://a_user@some.feed.server/enterprise/data-feed/{DEFAULT_VERSION}/", ) self.assertEqual( args.port_lists_url, f"ssh://a_user@some.feed.server/enterprise/data-feed/{DEFAULT_VERSION}/port-lists/", ) self.assertEqual( args.report_formats_url, f"ssh://a_user@some.feed.server/enterprise/data-feed/{DEFAULT_VERSION}/report-formats/", ) self.assertEqual( args.scan_configs_url, f"ssh://a_user@some.feed.server/enterprise/data-feed/{DEFAULT_VERSION}/scan-configs/", ) self.assertEqual( args.notus_url, f"ssh://a_user@some.feed.server/enterprise/vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", ) self.assertEqual( args.nasl_url, f"ssh://a_user@some.feed.server/enterprise/vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/", ) self.assertEqual( args.scap_data_url, f"ssh://a_user@some.feed.server/enterprise/vulnerability-feed/{DEFAULT_VERSION}/scap-data/", ) self.assertEqual( args.cert_data_url, f"ssh://a_user@some.feed.server/enterprise/vulnerability-feed/{DEFAULT_VERSION}/cert-data/", ) def test_ignore_non_existing_enterprise_feed_key(self): parser = CliParser() args = parser.parse_arguments( ["--greenbone-enterprise-feed-key", "/tmp/some.key"] ) self.assertEqual( args.feed_url, "rsync://feed.community.greenbone.net/community" ) self.assertEqual( args.gvmd_data_url, f"rsync://feed.community.greenbone.net/community/data-feed/{DEFAULT_VERSION}/", ) self.assertEqual( args.port_lists_url, f"rsync://feed.community.greenbone.net/community/data-feed/{DEFAULT_VERSION}/port-lists/", ) self.assertEqual( args.report_formats_url, f"rsync://feed.community.greenbone.net/community/data-feed/{DEFAULT_VERSION}/report-formats/", ) self.assertEqual( args.scan_configs_url, f"rsync://feed.community.greenbone.net/community/data-feed/{DEFAULT_VERSION}/scan-configs/", ) self.assertEqual( args.notus_url, f"rsync://feed.community.greenbone.net/community/vulnerability-feed/{DEFAULT_VERSION}/vt-data/notus/", ) self.assertEqual( args.nasl_url, f"rsync://feed.community.greenbone.net/community/vulnerability-feed/{DEFAULT_VERSION}/vt-data/nasl/", ) self.assertEqual( args.scap_data_url, f"rsync://feed.community.greenbone.net/community/vulnerability-feed/{DEFAULT_VERSION}/scap-data/", ) self.assertEqual( args.cert_data_url, f"rsync://feed.community.greenbone.net/community/vulnerability-feed/{DEFAULT_VERSION}/cert-data/", ) @patch.object(sys, "argv", ["greenbone-nvt-sync"]) def test_greenbone_nvt_sync(self): parser = CliParser() args = parser.parse_arguments([]) self.assertEqual(args.type, "nvt") @patch.object(sys, "argv", ["greenbone-scapdata-sync"]) def test_greenbone_scap_data_sync(self): parser = CliParser() args = parser.parse_arguments([]) self.assertEqual(args.type, "scap") @patch.object(sys, "argv", ["greenbone-certdata-sync"]) def test_greenbone_cert_data_sync(self): parser = CliParser() args = parser.parse_arguments([]) self.assertEqual(args.type, "cert") greenbone-feed-sync-24.3.0/tests/test_rsync.py000066400000000000000000000163551457600213200213420ustar00rootroot00000000000000# SPDX-FileCopyrightText: 2023-2024 Greenbone AG # # SPDX-License-Identifier: GPL-3.0-or-later # import asyncio import unittest from asyncio.subprocess import Process from pathlib import Path from unittest.mock import AsyncMock, patch from greenbone.feed.sync.errors import RsyncError from greenbone.feed.sync.rsync import Rsync, exec_rsync class RsyncTestCase(unittest.IsolatedAsyncioTestCase): @patch("greenbone.feed.sync.rsync.exec_rsync", autospec=True) async def test_rsync_with_defaults(self, exec_mock: AsyncMock): rsync = Rsync() await rsync.sync("rsync://foo.bar/baz", "/tmp/baz") exec_mock.assert_awaited_once_with( "--links", "--times", "--omit-dir-times", "--recursive", "--partial", "--progress", "-q", "--compress-level=9", "--delete", "--perms", "--chmod=Fugo+r,Fug+w,Dugo-s,Dugo+rx,Dug+w", "--copy-unsafe-links", "--hard-links", "rsync://foo.bar/baz", "/tmp/baz", ) @patch("greenbone.feed.sync.rsync.exec_rsync", autospec=True) async def test_rsync_with_private_subdir(self, exec_mock: AsyncMock): rsync = Rsync(private_subdir="private") await rsync.sync("rsync://foo.bar/baz", "/tmp/baz") exec_mock.assert_awaited_once_with( "--links", "--times", "--omit-dir-times", "--recursive", "--partial", "--progress", "-q", "--compress-level=9", "--delete", "--exclude", "private", "--perms", "--chmod=Fugo+r,Fug+w,Dugo-s,Dugo+rx,Dug+w", "--copy-unsafe-links", "--hard-links", "rsync://foo.bar/baz", "/tmp/baz", ) @patch("greenbone.feed.sync.rsync.exec_rsync", autospec=True) async def test_rsync_with_verbose(self, exec_mock: AsyncMock): rsync = Rsync(verbose=True) await rsync.sync("rsync://foo.bar/baz", "/tmp/baz") exec_mock.assert_awaited_once_with( "--links", "--times", "--omit-dir-times", "--recursive", "--partial", "--progress", "-v", "--compress-level=9", "--delete", "--perms", "--chmod=Fugo+r,Fug+w,Dugo-s,Dugo+rx,Dug+w", "--copy-unsafe-links", "--hard-links", "rsync://foo.bar/baz", "/tmp/baz", ) @patch("greenbone.feed.sync.rsync.exec_rsync", autospec=True) async def test_rsync_with_compression_level(self, exec_mock: AsyncMock): rsync = Rsync(compression_level=1) await rsync.sync("rsync://foo.bar/baz", "/tmp/baz") exec_mock.assert_awaited_once_with( "--links", "--times", "--omit-dir-times", "--recursive", "--partial", "--progress", "-q", "--compress-level=1", "--delete", "--perms", "--chmod=Fugo+r,Fug+w,Dugo-s,Dugo+rx,Dug+w", "--copy-unsafe-links", "--hard-links", "rsync://foo.bar/baz", "/tmp/baz", ) @patch("greenbone.feed.sync.rsync.exec_rsync", autospec=True) async def test_rsync_with_exclude(self, exec_mock: AsyncMock): rsync = Rsync(exclude=["foo", Path("exclude/this")]) await rsync.sync("rsync://foo.bar/baz", "/tmp/baz") exec_mock.assert_awaited_once_with( "--links", "--times", "--omit-dir-times", "--recursive", "--partial", "--progress", "-q", "--compress-level=9", "--delete", "--exclude", "foo", "--exclude", "exclude/this", "--perms", "--chmod=Fugo+r,Fug+w,Dugo-s,Dugo+rx,Dug+w", "--copy-unsafe-links", "--hard-links", "rsync://foo.bar/baz", "/tmp/baz", ) class ExecRsyncTestCase(unittest.IsolatedAsyncioTestCase): @patch( "greenbone.feed.sync.rsync.asyncio.create_subprocess_exec", autospec=True, ) async def test_failure(self, exec_mock: AsyncMock): process_mock = AsyncMock(spec=Process) process_mock.communicate.return_value = (None, b"An error occurred") process_mock.wait.return_value = 1 exec_mock.return_value = process_mock with self.assertRaises(RsyncError) as cm: await exec_rsync("foo", "bar") exec_mock.assert_awaited_once_with( "rsync", "foo", "bar", stderr=asyncio.subprocess.PIPE ) self.assertEqual(cm.exception.returncode, 1) self.assertEqual(cm.exception.stderr, "An error occurred") self.assertEqual(cm.exception.cmd, ["rsync", "foo", "bar"]) self.assertIsNone(cm.exception.stout) self.assertEqual( str(cm.exception), "'rsync foo bar' returned non-zero exit status 1.", ) @patch( "greenbone.feed.sync.rsync.asyncio.create_subprocess_exec", autospec=True, ) async def test_success(self, exec_mock: AsyncMock): process_mock = AsyncMock(spec=Process) process_mock.communicate.return_value = (None, None) process_mock.wait.return_value = 0 exec_mock.return_value = process_mock await exec_rsync("foo", "bar") exec_mock.assert_awaited_once_with( "rsync", "foo", "bar", stderr=asyncio.subprocess.PIPE ) @patch("greenbone.feed.sync.rsync.exec_rsync", autospec=True) async def test_rsync_with_timeout(self, exec_mock: AsyncMock): rsync = Rsync(timeout=120) await rsync.sync("rsync://foo.bar/baz", "/tmp/baz") exec_mock.assert_awaited_once_with( "--links", "--times", "--omit-dir-times", "--recursive", "--partial", "--progress", "--timeout=120", "-q", "--compress-level=9", "--delete", "--perms", "--chmod=Fugo+r,Fug+w,Dugo-s,Dugo+rx,Dug+w", "--copy-unsafe-links", "--hard-links", "rsync://foo.bar/baz", "/tmp/baz", ) @patch("greenbone.feed.sync.rsync.exec_rsync", autospec=True) async def test_rsync_with_ssh(self, exec_mock: AsyncMock): ssh_key = Path("/tmp/ssh.key") rsync = Rsync(ssh_key=ssh_key) await rsync.sync("ssh://user@foo.bar/baz", "/tmp/baz") exec_mock.assert_awaited_once_with( "--links", "--times", "--omit-dir-times", "--recursive", "--partial", "--progress", "-e", "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 24 -i '/tmp/ssh.key'", # pylint: disable=line-too-long # noqa: E501 "-q", "--compress-level=9", "--delete", "--perms", "--chmod=Fugo+r,Fug+w,Dugo-s,Dugo+rx,Dug+w", "--copy-unsafe-links", "--hard-links", "user@foo.bar:/baz", "/tmp/baz", )