From 27205f5cd017530632f6660ab21b3d7e7b4c2b09 Mon Sep 17 00:00:00 2001 From: Patrik Spiess Date: Mon, 13 Jan 2025 15:44:02 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WHATSNEW.md | 1 + poetry.lock | 145 +++++++++++++++++++++++--- pyproject.toml | 6 +- tests/fortinet/test_forticlientems.py | 6 +- 4 files changed, 138 insertions(+), 20 deletions(-) diff --git a/WHATSNEW.md b/WHATSNEW.md index 01f375e..4515f97 100644 --- a/WHATSNEW.md +++ b/WHATSNEW.md @@ -11,6 +11,7 @@ ### Changed - Optimize imports in CLI module +- Upgrade requests, jinja and pygount due to security issues and bugs ### Removed diff --git a/poetry.lock b/poetry.lock index db85e59..c455b55 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.0.0 and should not be changed by hand. [[package]] name = "alabaster" @@ -6,6 +6,7 @@ version = "0.7.13" description = "A configurable sidebar-enabled Sphinx theme" optional = false python-versions = ">=3.6" +groups = ["docs"] files = [ {file = "alabaster-0.7.13-py3-none-any.whl", hash = "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3"}, {file = "alabaster-0.7.13.tar.gz", hash = "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2"}, @@ -17,6 +18,7 @@ version = "3.1.0" description = "An abstract syntax tree for Python with inference support." optional = false python-versions = ">=3.8.0" +groups = ["dev"] files = [ {file = "astroid-3.1.0-py3-none-any.whl", hash = "sha256:951798f922990137ac090c53af473db7ab4e70c770e6d7fae0cec59f74411819"}, {file = "astroid-3.1.0.tar.gz", hash = "sha256:ac248253bfa4bd924a0de213707e7ebeeb3138abeb48d798784ead1e56d419d4"}, @@ -31,6 +33,7 @@ version = "23.2.0" description = "Classes Without Boilerplate" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, @@ -50,6 +53,7 @@ version = "2.15.0" description = "Internationalization utilities" optional = false python-versions = ">=3.8" +groups = ["docs"] files = [ {file = "Babel-2.15.0-py3-none-any.whl", hash = "sha256:08706bdad8d0a3413266ab61bd6c34d0c28d6e1e7badf40a2cebe67644e2e1fb"}, {file = "babel-2.15.0.tar.gz", hash = "sha256:8daf0e265d05768bc6c7a314cf1321e9a123afc328cc635c18622a2f30a04413"}, @@ -67,6 +71,7 @@ version = "24.3.0" description = "The uncompromising code formatter." optional = false python-versions = ">=3.8" +groups = ["dev"] 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"}, @@ -113,6 +118,7 @@ version = "5.3.3" description = "Extensible memoizing collections and decorators" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "cachetools-5.3.3-py3-none-any.whl", hash = "sha256:0abad1021d3f8325b2fc1d2e9c8b9c9d57b04c3932657a72465447332c24d945"}, {file = "cachetools-5.3.3.tar.gz", hash = "sha256:ba29e2dfa0b8b556606f097407ed1aa62080ee108ab0dc5ec9d6a723a007d105"}, @@ -124,6 +130,7 @@ version = "2024.7.4" description = "Python package for providing Mozilla's CA Bundle." optional = false python-versions = ">=3.6" +groups = ["main", "docs"] files = [ {file = "certifi-2024.7.4-py3-none-any.whl", hash = "sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90"}, {file = "certifi-2024.7.4.tar.gz", hash = "sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b"}, @@ -135,6 +142,7 @@ version = "5.2.0" description = "Universal encoding detector for Python 3" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "chardet-5.2.0-py3-none-any.whl", hash = "sha256:e1cf59446890a00105fe7b7912492ea04b6e6f06d4b742b2c788469e34c82970"}, {file = "chardet-5.2.0.tar.gz", hash = "sha256:1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7"}, @@ -146,6 +154,7 @@ version = "3.3.2" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." optional = false python-versions = ">=3.7.0" +groups = ["main", "docs"] files = [ {file = "charset-normalizer-3.3.2.tar.gz", hash = "sha256:f30c3cb33b24454a82faecaf01b19c18562b1e89558fb6c56de4d9118a032fd5"}, {file = "charset_normalizer-3.3.2-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:25baf083bf6f6b341f4121c2f3c548875ee6f5339300e08be3f2b2ba1721cdd3"}, @@ -245,6 +254,7 @@ version = "8.1.7" description = "Composable command line interface toolkit" optional = false python-versions = ">=3.7" +groups = ["main", "dev"] files = [ {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, @@ -259,10 +269,12 @@ 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" +groups = ["main", "dev", "docs"] files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +markers = {main = "platform_system == \"Windows\"", docs = "sys_platform == \"win32\""} [[package]] name = "commonmark" @@ -270,6 +282,7 @@ version = "0.9.1" description = "Python parser for the CommonMark Markdown spec" optional = false python-versions = "*" +groups = ["main", "dev"] files = [ {file = "commonmark-0.9.1-py2.py3-none-any.whl", hash = "sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9"}, {file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"}, @@ -284,6 +297,7 @@ version = "7.5.1" description = "Code coverage measurement for Python" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "coverage-7.5.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:c0884920835a033b78d1c73b6d3bbcda8161a900f38a488829a83982925f6c2e"}, {file = "coverage-7.5.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:39afcd3d4339329c5f58de48a52f6e4e50f6578dd6099961cf22228feb25f38f"}, @@ -351,6 +365,7 @@ version = "0.3.8" description = "serialize all of Python" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "dill-0.3.8-py3-none-any.whl", hash = "sha256:c36ca9ffb54365bdd2f8eb3eff7d2a21237f8452b57ace88b1ac615b7e815bd7"}, {file = "dill-0.3.8.tar.gz", hash = "sha256:3ebe3c479ad625c4553aca177444d89b486b1d84982eeacded644afc0cf797ca"}, @@ -366,6 +381,7 @@ version = "0.3.8" description = "Distribution utilities" optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "distlib-0.3.8-py2.py3-none-any.whl", hash = "sha256:034db59a0b96f8ca18035f36290806a9a6e6bd9d1ff91e45a7f172eb17e51784"}, {file = "distlib-0.3.8.tar.gz", hash = "sha256:1530ea13e350031b6312d8580ddb6b27a104275a31106523b8f123787f494f64"}, @@ -377,6 +393,7 @@ version = "0.18.1" description = "Docutils -- Python Documentation Utilities" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +groups = ["docs"] files = [ {file = "docutils-0.18.1-py2.py3-none-any.whl", hash = "sha256:23010f129180089fbcd3bc08cfefccb3b890b0050e1ca00c867036e9d161b98c"}, {file = "docutils-0.18.1.tar.gz", hash = "sha256:679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06"}, @@ -388,6 +405,8 @@ version = "1.2.1" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version < \"3.11\"" files = [ {file = "exceptiongroup-1.2.1-py3-none-any.whl", hash = "sha256:5258b9ed329c5bbdd31a309f53cbfb0b155341807f6ff7606a1e801a891b29ad"}, {file = "exceptiongroup-1.2.1.tar.gz", hash = "sha256:a4785e48b045528f5bfe627b6ad554ff32def154f42372786903b7abcfe1aa16"}, @@ -402,6 +421,7 @@ version = "3.14.0" description = "A platform independent file lock." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "filelock-3.14.0-py3-none-any.whl", hash = "sha256:43339835842f110ca7ae60f1e1c160714c5a6afd15a2873419ab185334975c0f"}, {file = "filelock-3.14.0.tar.gz", hash = "sha256:6ea72da3be9b8c82afd3edcf99f2fffbb5076335a5ae4d03248bb5b6c3eae78a"}, @@ -412,12 +432,47 @@ docs = ["furo (>=2023.9.10)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1 testing = ["covdefaults (>=2.3)", "coverage (>=7.3.2)", "diff-cover (>=8.0.1)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)", "pytest-timeout (>=2.2)"] typing = ["typing-extensions (>=4.8)"] +[[package]] +name = "gitdb" +version = "4.0.12" +description = "Git Object Database" +optional = false +python-versions = ">=3.7" +groups = ["dev"] +files = [ + {file = "gitdb-4.0.12-py3-none-any.whl", hash = "sha256:67073e15955400952c6565cc3e707c554a4eea2e428946f7a4c162fab9bd9bcf"}, + {file = "gitdb-4.0.12.tar.gz", hash = "sha256:5ef71f855d191a3326fcfbc0d5da835f26b13fbcba60c32c21091c349ffdb571"}, +] + +[package.dependencies] +smmap = ">=3.0.1,<6" + +[[package]] +name = "gitpython" +version = "3.1.44" +description = "GitPython is a Python library used to interact with Git repositories" +optional = false +python-versions = ">=3.7" +groups = ["dev"] +files = [ + {file = "GitPython-3.1.44-py3-none-any.whl", hash = "sha256:9e0e10cda9bed1ee64bc9a6de50e7e38a9c9943241cd7f585f6df3ed28011110"}, + {file = "gitpython-3.1.44.tar.gz", hash = "sha256:c87e30b26253bf5418b01b0660f818967f3c503193838337fe5e573331249269"}, +] + +[package.dependencies] +gitdb = ">=4.0.1,<5" + +[package.extras] +doc = ["sphinx (>=7.1.2,<7.2)", "sphinx-autodoc-typehints", "sphinx_rtd_theme"] +test = ["coverage[toml]", "ddt (>=1.1.1,!=1.4.3)", "mock", "mypy", "pre-commit", "pytest (>=7.3.1)", "pytest-cov", "pytest-instafail", "pytest-mock", "pytest-sugar", "typing-extensions"] + [[package]] name = "idna" version = "3.7" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.5" +groups = ["main", "docs"] files = [ {file = "idna-3.7-py3-none-any.whl", hash = "sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0"}, {file = "idna-3.7.tar.gz", hash = "sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc"}, @@ -429,6 +484,7 @@ version = "1.4.1" description = "Getting image size from png/jpeg/jpeg2000/gif file" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +groups = ["docs"] files = [ {file = "imagesize-1.4.1-py2.py3-none-any.whl", hash = "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b"}, {file = "imagesize-1.4.1.tar.gz", hash = "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a"}, @@ -440,6 +496,8 @@ version = "7.1.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" +groups = ["docs"] +markers = "python_version < \"3.10\"" files = [ {file = "importlib_metadata-7.1.0-py3-none-any.whl", hash = "sha256:30962b96c0c223483ed6cc7280e7f0199feb01a0e40cfae4d4450fc6fab1f570"}, {file = "importlib_metadata-7.1.0.tar.gz", hash = "sha256:b78938b926ee8d5f020fc4772d487045805a55ddbad2ecf21c6d60938dc7fcd2"}, @@ -459,6 +517,7 @@ version = "2.0.0" description = "brain-dead simple config-ini parsing" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, @@ -470,6 +529,7 @@ version = "5.10.1" description = "A Python utility / library to sort Python imports." optional = false python-versions = ">=3.6.1,<4.0" +groups = ["dev"] files = [ {file = "isort-5.10.1-py3-none-any.whl", hash = "sha256:6f62d78e2f89b4500b080fe3a81690850cd254227f27f75c3a0c491a1f351ba7"}, {file = "isort-5.10.1.tar.gz", hash = "sha256:e8443a5e7a020e9d7f97f1d7d9cd17c88bcb3bc7e218bf9cf5095fe550be2951"}, @@ -483,13 +543,14 @@ requirements-deprecated-finder = ["pip-api", "pipreqs"] [[package]] name = "jinja2" -version = "3.1.4" +version = "3.1.5" description = "A very fast and expressive template engine." optional = false python-versions = ">=3.7" +groups = ["main", "docs"] files = [ - {file = "jinja2-3.1.4-py3-none-any.whl", hash = "sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d"}, - {file = "jinja2-3.1.4.tar.gz", hash = "sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369"}, + {file = "jinja2-3.1.5-py3-none-any.whl", hash = "sha256:aba0f4dc9ed8013c424088f68a5c226f7d6097ed89b246d7749c2ec4175c6adb"}, + {file = "jinja2-3.1.5.tar.gz", hash = "sha256:8fefff8dc3034e27bb80d67c671eb8a9bc424c0ef4c0826edbff304cceff43bb"}, ] [package.dependencies] @@ -504,6 +565,7 @@ version = "2.1.5" description = "Safely add untrusted strings to HTML/XML markup." optional = false python-versions = ">=3.7" +groups = ["main", "docs"] files = [ {file = "MarkupSafe-2.1.5-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a17a92de5231666cfbe003f0e4b9b3a7ae3afb1ec2845aadc2bacc93ff85febc"}, {file = "MarkupSafe-2.1.5-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:72b6be590cc35924b02c78ef34b467da4ba07e4e0f0454a2c5907f473fc50ce5"}, @@ -573,6 +635,7 @@ version = "0.7.0" description = "McCabe checker, plugin for flake8" optional = false python-versions = ">=3.6" +groups = ["dev"] files = [ {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, @@ -584,6 +647,7 @@ version = "0.991" description = "Optional static typing for Python" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "mypy-0.991-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:7d17e0a9707d0772f4a7b878f04b4fd11f6f5bcb9b3813975a9b13c9332153ab"}, {file = "mypy-0.991-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:0714258640194d75677e86c786e80ccf294972cc76885d3ebbb560f11db0003d"}, @@ -634,6 +698,7 @@ version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." optional = false python-versions = ">=3.5" +groups = ["dev"] 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"}, @@ -645,6 +710,7 @@ version = "24.0" description = "Core utilities for Python packages" optional = false python-versions = ">=3.7" +groups = ["dev", "docs"] files = [ {file = "packaging-24.0-py3-none-any.whl", hash = "sha256:2ddfb553fdf02fb784c234c7ba6ccc288296ceabec964ad2eae3777778130bc5"}, {file = "packaging-24.0.tar.gz", hash = "sha256:eb82c5e3e56209074766e6885bb04b8c38a0c015d0a30036ebe7ece34c9989e9"}, @@ -656,6 +722,7 @@ version = "0.12.1" description = "Utility library for gitignore style pattern matching of file paths." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, @@ -667,6 +734,7 @@ version = "4.2.2" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "platformdirs-4.2.2-py3-none-any.whl", hash = "sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee"}, {file = "platformdirs-4.2.2.tar.gz", hash = "sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3"}, @@ -683,6 +751,7 @@ version = "1.5.0" description = "plugin and hook calling mechanisms for python" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669"}, {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, @@ -698,6 +767,7 @@ version = "2.18.0" description = "Pygments is a syntax highlighting package written in Python." optional = false python-versions = ">=3.8" +groups = ["main", "dev", "docs"] files = [ {file = "pygments-2.18.0-py3-none-any.whl", hash = "sha256:b8e6aca0523f3ab76fee51799c488e38782ac06eafcf95e7ba832985c8e7b13a"}, {file = "pygments-2.18.0.tar.gz", hash = "sha256:786ff802f32e91311bff3889f6e9a86e81505fe99f2735bb6d60ae0c5004f199"}, @@ -708,19 +778,21 @@ windows-terminal = ["colorama (>=0.4.6)"] [[package]] name = "pygount" -version = "1.5.1" +version = "1.8.0" description = "count source lines of code (SLOC) using pygments" optional = false -python-versions = ">=3.7,<4" +python-versions = "<3.13,>=3.8" +groups = ["dev"] files = [ - {file = "pygount-1.5.1-py3-none-any.whl", hash = "sha256:6f5c642809b76cec99d238cdf4bcf9a8e3712247a18f3799ad893171c44a4c5b"}, - {file = "pygount-1.5.1.tar.gz", hash = "sha256:022987889d6b604382d89c66168f5077f9ef2f2c225a8d60883bfed6180dbcfe"}, + {file = "pygount-1.8.0-py3-none-any.whl", hash = "sha256:bb4e27ae3709674a91e349f503240ffeaef7efa59d1e026c7e4b2278dd3deb7f"}, + {file = "pygount-1.8.0.tar.gz", hash = "sha256:a1c530a8ff473c99dc7cd24b034f382d60f51efcac3a1d2181642124dbda2173"}, ] [package.dependencies] chardet = ">=5,<6" +gitpython = ">=3,<4" pygments = ">=2,<3" -rich = ">=9,<13" +rich = ">=9,<14" [[package]] name = "pylint" @@ -728,6 +800,7 @@ version = "3.1.1" description = "python code static checker" optional = false python-versions = ">=3.8.0" +groups = ["dev"] files = [ {file = "pylint-3.1.1-py3-none-any.whl", hash = "sha256:862eddf25dab42704c5f06d3688b8bc19ef4c99ad8a836b6ff260a3b2fbafee1"}, {file = "pylint-3.1.1.tar.gz", hash = "sha256:c7c2652bf8099c7fb7a63bc6af5c5f8f7b9d7b392fa1d320cb020e222aff28c2"}, @@ -758,6 +831,7 @@ version = "1.6.1" description = "API to interact with the python pyproject.toml based projects" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "pyproject_api-1.6.1-py3-none-any.whl", hash = "sha256:4c0116d60476b0786c88692cf4e325a9814965e2469c5998b830bba16b183675"}, {file = "pyproject_api-1.6.1.tar.gz", hash = "sha256:1817dc018adc0d1ff9ca1ed8c60e1623d5aaca40814b953af14a9cf9a5cae538"}, @@ -777,6 +851,7 @@ version = "7.2.2" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "pytest-7.2.2-py3-none-any.whl", hash = "sha256:130328f552dcfac0b1cec75c12e3f005619dc5f874f0a06e8ff7263f0ee6225e"}, {file = "pytest-7.2.2.tar.gz", hash = "sha256:c99ab0c73aceb050f68929bc93af19ab6db0558791c6a0715723abe9d0ade9d4"}, @@ -800,6 +875,7 @@ version = "4.0.0" description = "Pytest plugin for measuring coverage." optional = false python-versions = ">=3.6" +groups = ["dev"] files = [ {file = "pytest-cov-4.0.0.tar.gz", hash = "sha256:996b79efde6433cdbd0088872dbc5fb3ed7fe1578b68cdbba634f14bb8dd0470"}, {file = "pytest_cov-4.0.0-py3-none-any.whl", hash = "sha256:2feb1b751d66a8bd934e5edfa2e961d11309dc37b73b0eabe73b5945fee20f6b"}, @@ -818,6 +894,8 @@ version = "2024.1" description = "World timezone definitions, modern and historical" optional = false python-versions = "*" +groups = ["docs"] +markers = "python_version < \"3.9\"" files = [ {file = "pytz-2024.1-py2.py3-none-any.whl", hash = "sha256:328171f4e3623139da4983451950b28e95ac706e13f3f2630a879749e7a8b319"}, {file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"}, @@ -829,6 +907,7 @@ version = "6.0.1" description = "YAML parser and emitter for Python" optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "PyYAML-6.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d858aa552c999bc8a8d57426ed01e40bef403cd8ccdd0fc5f6f04a00414cac2a"}, {file = "PyYAML-6.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:fd66fc5d0da6d9815ba2cebeb4205f95818ff4b79c3ebe268e75d961704af52f"}, @@ -885,13 +964,14 @@ files = [ [[package]] name = "requests" -version = "2.32.1" +version = "2.32.3" description = "Python HTTP for Humans." optional = false python-versions = ">=3.8" +groups = ["main", "docs"] files = [ - {file = "requests-2.32.1-py3-none-any.whl", hash = "sha256:21ac9465cdf8c1650fe1ecde8a71669a93d4e6f147550483a2967d08396a56a5"}, - {file = "requests-2.32.1.tar.gz", hash = "sha256:eb97e87e64c79e64e5b8ac75cee9dd1f97f49e289b083ee6be96268930725685"}, + {file = "requests-2.32.3-py3-none-any.whl", hash = "sha256:70761cfe03c773ceb22aa2f671b4757976145175cdfca038c02654d061d6dcc6"}, + {file = "requests-2.32.3.tar.gz", hash = "sha256:55365417734eb18255590a9ff9eb97e9e1da868d4ccd6402399eaf68af20a760"}, ] [package.dependencies] @@ -910,6 +990,7 @@ version = "12.5.1" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" optional = false python-versions = ">=3.6.3,<4.0.0" +groups = ["main", "dev"] files = [ {file = "rich-12.5.1-py3-none-any.whl", hash = "sha256:2eb4e6894cde1e017976d2975ac210ef515d7548bc595ba20e195fb9628acdeb"}, {file = "rich-12.5.1.tar.gz", hash = "sha256:63a5c5ce3673d3d5fbbf23cd87e11ab84b6b451436f1b7f19ec54b6bc36ed7ca"}, @@ -923,12 +1004,25 @@ typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9 [package.extras] jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] +[[package]] +name = "smmap" +version = "5.0.2" +description = "A pure Python implementation of a sliding window memory map manager" +optional = false +python-versions = ">=3.7" +groups = ["dev"] +files = [ + {file = "smmap-5.0.2-py3-none-any.whl", hash = "sha256:b30115f0def7d7531d22a0fb6502488d879e75b260a9db4d0819cfb25403af5e"}, + {file = "smmap-5.0.2.tar.gz", hash = "sha256:26ea65a03958fa0c8a1c7e8c7a58fdc77221b8910f6be2131affade476898ad5"}, +] + [[package]] name = "snowballstemmer" version = "2.2.0" description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." optional = false python-versions = "*" +groups = ["docs"] files = [ {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, @@ -940,6 +1034,7 @@ version = "6.2.1" description = "Python documentation generator" optional = false python-versions = ">=3.8" +groups = ["docs"] files = [ {file = "Sphinx-6.2.1.tar.gz", hash = "sha256:6d56a34697bb749ffa0152feafc4b19836c755d90a7c59b72bc7dfd371b9cc6b"}, {file = "sphinx-6.2.1-py3-none-any.whl", hash = "sha256:97787ff1fa3256a3eef9eda523a63dbf299f7b47e053cfcf684a1c2a8380c912"}, @@ -975,6 +1070,7 @@ version = "1.2.2" description = "Read the Docs theme for Sphinx" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,>=2.7" +groups = ["docs"] files = [ {file = "sphinx_rtd_theme-1.2.2-py2.py3-none-any.whl", hash = "sha256:6a7e7d8af34eb8fc57d52a09c6b6b9c46ff44aea5951bc831eeb9245378f3689"}, {file = "sphinx_rtd_theme-1.2.2.tar.gz", hash = "sha256:01c5c5a72e2d025bd23d1f06c59a4831b06e6ce6c01fdd5ebfe9986c0a880fc7"}, @@ -994,6 +1090,7 @@ version = "1.0.4" description = "sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books" optional = false python-versions = ">=3.8" +groups = ["docs"] files = [ {file = "sphinxcontrib-applehelp-1.0.4.tar.gz", hash = "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e"}, {file = "sphinxcontrib_applehelp-1.0.4-py3-none-any.whl", hash = "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228"}, @@ -1009,6 +1106,7 @@ version = "1.0.2" description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp document." optional = false python-versions = ">=3.5" +groups = ["docs"] files = [ {file = "sphinxcontrib-devhelp-1.0.2.tar.gz", hash = "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4"}, {file = "sphinxcontrib_devhelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e"}, @@ -1024,6 +1122,7 @@ version = "2.0.1" description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" optional = false python-versions = ">=3.8" +groups = ["docs"] files = [ {file = "sphinxcontrib-htmlhelp-2.0.1.tar.gz", hash = "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff"}, {file = "sphinxcontrib_htmlhelp-2.0.1-py3-none-any.whl", hash = "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903"}, @@ -1039,6 +1138,7 @@ version = "4.1" description = "Extension to include jQuery on newer Sphinx releases" optional = false python-versions = ">=2.7" +groups = ["docs"] files = [ {file = "sphinxcontrib-jquery-4.1.tar.gz", hash = "sha256:1620739f04e36a2c779f1a131a2dfd49b2fd07351bf1968ced074365933abc7a"}, {file = "sphinxcontrib_jquery-4.1-py2.py3-none-any.whl", hash = "sha256:f936030d7d0147dd026a4f2b5a57343d233f1fc7b363f68b3d4f1cb0993878ae"}, @@ -1053,6 +1153,7 @@ version = "1.0.1" description = "A sphinx extension which renders display math in HTML via JavaScript" optional = false python-versions = ">=3.5" +groups = ["docs"] files = [ {file = "sphinxcontrib-jsmath-1.0.1.tar.gz", hash = "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8"}, {file = "sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl", hash = "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178"}, @@ -1067,6 +1168,7 @@ version = "1.0.3" description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp document." optional = false python-versions = ">=3.5" +groups = ["docs"] files = [ {file = "sphinxcontrib-qthelp-1.0.3.tar.gz", hash = "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72"}, {file = "sphinxcontrib_qthelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6"}, @@ -1082,6 +1184,7 @@ version = "1.1.5" description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)." optional = false python-versions = ">=3.5" +groups = ["docs"] files = [ {file = "sphinxcontrib-serializinghtml-1.1.5.tar.gz", hash = "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952"}, {file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"}, @@ -1097,6 +1200,8 @@ version = "2.0.1" description = "A lil' TOML parser" optional = false python-versions = ">=3.7" +groups = ["dev"] +markers = "python_version < \"3.11\"" files = [ {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, @@ -1108,6 +1213,7 @@ version = "0.12.5" description = "Style preserving TOML library" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "tomlkit-0.12.5-py3-none-any.whl", hash = "sha256:af914f5a9c59ed9d0762c7b64d3b5d5df007448eb9cd2edc8a46b1eafead172f"}, {file = "tomlkit-0.12.5.tar.gz", hash = "sha256:eef34fba39834d4d6b73c9ba7f3e4d1c417a4e56f89a7e96e090dd0d24b8fb3c"}, @@ -1119,6 +1225,7 @@ version = "4.4.12" description = "tox is a generic virtualenv management and test command line tool" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "tox-4.4.12-py3-none-any.whl", hash = "sha256:d4be558809d86fad13f4553976b0500352630a8fbfa39ea4b1ce3bd945ba680b"}, {file = "tox-4.4.12.tar.gz", hash = "sha256:740f5209d0dec19451b951ee5b1cce4a207acdc7357af84dbc8ec35bcf2c454e"}, @@ -1146,6 +1253,7 @@ version = "0.6.1" description = "Typer, build great CLIs. Easy to code. Based on Python type hints." optional = false python-versions = ">=3.6" +groups = ["main"] files = [ {file = "typer-0.6.1-py3-none-any.whl", hash = "sha256:54b19e5df18654070a82f8c2aa1da456a4ac16a2a83e6dcd9f170e291c56338e"}, {file = "typer-0.6.1.tar.gz", hash = "sha256:2d5720a5e63f73eaf31edaa15f6ab87f35f0690f8ca233017d7d23d743a91d73"}, @@ -1166,6 +1274,7 @@ version = "6.0.12.20240311" description = "Typing stubs for PyYAML" optional = false python-versions = ">=3.8" +groups = ["dev"] files = [ {file = "types-PyYAML-6.0.12.20240311.tar.gz", hash = "sha256:a9e0f0f88dc835739b0c1ca51ee90d04ca2a897a71af79de9aec5f38cb0a5342"}, {file = "types_PyYAML-6.0.12.20240311-py3-none-any.whl", hash = "sha256:b845b06a1c7e54b8e5b4c683043de0d9caf205e7434b3edc678ff2411979b8f6"}, @@ -1177,6 +1286,7 @@ version = "2.27.31" description = "Typing stubs for requests" optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "types-requests-2.27.31.tar.gz", hash = "sha256:6fab97b99fea52b9c7b466a4dd93e06bb325bc7e7420475e87831026a8dd35cc"}, {file = "types_requests-2.27.31-py3-none-any.whl", hash = "sha256:1b6cf6a2bf57fd8018c1b636b69762900466fafddfb62e1330e092f3d4b0966a"}, @@ -1191,6 +1301,7 @@ version = "1.26.25.14" description = "Typing stubs for urllib3" optional = false python-versions = "*" +groups = ["dev"] files = [ {file = "types-urllib3-1.26.25.14.tar.gz", hash = "sha256:229b7f577c951b8c1b92c1bc2b2fdb0b49847bd2af6d1cc2a2e3dd340f3bda8f"}, {file = "types_urllib3-1.26.25.14-py3-none-any.whl", hash = "sha256:9683bbb7fb72e32bfe9d2be6e04875fbe1b3eeec3cbb4ea231435aa7fd6b4f0e"}, @@ -1202,10 +1313,12 @@ version = "4.11.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" +groups = ["main", "dev"] files = [ {file = "typing_extensions-4.11.0-py3-none-any.whl", hash = "sha256:c1f94d72897edaf4ce775bb7558d5b79d8126906a14ea5ed1635921406c0387a"}, {file = "typing_extensions-4.11.0.tar.gz", hash = "sha256:83f085bd5ca59c80295fc2a82ab5dac679cbe02b9f33f7d83af68e241bea51b0"}, ] +markers = {main = "python_version < \"3.9\""} [[package]] name = "urllib3" @@ -1213,6 +1326,7 @@ version = "2.2.2" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.8" +groups = ["main", "docs"] files = [ {file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"}, {file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"}, @@ -1230,6 +1344,7 @@ version = "20.26.2" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" +groups = ["dev"] files = [ {file = "virtualenv-20.26.2-py3-none-any.whl", hash = "sha256:a624db5e94f01ad993d476b9ee5346fdf7b9de43ccaee0e0197012dc838a0e9b"}, {file = "virtualenv-20.26.2.tar.gz", hash = "sha256:82bf0f4eebbb78d36ddaee0283d43fe5736b53880b8a8cdcd37390a07ac3741c"}, @@ -1250,6 +1365,8 @@ version = "3.19.1" description = "Backport of pathlib-compatible object wrapper for zip files" optional = false python-versions = ">=3.8" +groups = ["docs"] +markers = "python_version < \"3.10\"" files = [ {file = "zipp-3.19.1-py3-none-any.whl", hash = "sha256:2828e64edb5386ea6a52e7ba7cdb17bb30a73a858f5eb6eb93d8d36f5ea26091"}, {file = "zipp-3.19.1.tar.gz", hash = "sha256:35427f6d5594f4acf82d25541438348c26736fa9b3afa2754bcd63cdb99d8e8f"}, @@ -1260,6 +1377,6 @@ doc = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linke test = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-itertools", "pytest (>=6,!=8.1.*)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy", "pytest-ruff (>=0.2.1)"] [metadata] -lock-version = "2.0" +lock-version = "2.1" python-versions = ">=3.8.0, <3.13" -content-hash = "25b733f81cac67280e379276e9a0081caecfc30290a9f90bc6dcf8aef9d2716a" +content-hash = "51b1c094460003e14deda96953770da745cb2cbae80337e8e2fe73d43acd2f3f" diff --git a/pyproject.toml b/pyproject.toml index 2c21661..25d52c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,8 +42,8 @@ python = ">=3.8.0, <3.13" typer = "~0.6.0" rich = "~12.5.1" PyYAML = "~6.0.0" -requests = ">=2.32" -Jinja2 = "~3.1.4" +requests = ">=2.32.3" +Jinja2 = "~3.1.5" [tool.poetry.group.dev.dependencies] pytest = "~7.2.0" @@ -55,7 +55,7 @@ pytest-cov = "~4.0.0" types-requests = "~2.27.11" isort = "~5.10.1" types-PyYAML = "~6.0.5" -pygount = "~1.5.0" +pygount = "~1.8.0" [tool.poetry.group.docs.dependencies] Sphinx = "~6.2.0" diff --git a/tests/fortinet/test_forticlientems.py b/tests/fortinet/test_forticlientems.py index f4472f2..ccdb877 100644 --- a/tests/fortinet/test_forticlientems.py +++ b/tests/fortinet/test_forticlientems.py @@ -131,7 +131,7 @@ def test_login_with_cookie_but_unable_to_save_it( requests.Session.post.assert_called_with( "https://ems_dummy:443/api/v1/auth/signin", headers={ - "User-Agent": "python-requests/2.32.1", + "User-Agent": "python-requests/2.32.3", "Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "keep-alive", @@ -179,7 +179,7 @@ def test_login_with_cookie_and_invalid_session( requests.Session.get.assert_called_with( "https://ems_dummy:443/api/v1/system/serial_number", headers={ - "User-Agent": "python-requests/2.32.1", + "User-Agent": "python-requests/2.32.3", "Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "keep-alive", @@ -194,7 +194,7 @@ def test_login_with_cookie_and_invalid_session( requests.Session.post.assert_called_with( "https://ems_dummy:443/api/v1/auth/signin", headers={ - "User-Agent": "python-requests/2.32.1", + "User-Agent": "python-requests/2.32.3", "Accept-Encoding": "gzip, deflate", "Accept": "*/*", "Connection": "keep-alive", From 5d70607c316ee34bcb4e175765d308e143d332cf Mon Sep 17 00:00:00 2001 From: Patrik Spiess Date: Mon, 13 Jan 2025 15:50:44 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Fix=20typing=20for?= =?UTF-8?q?=20Python3.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fotoobo/tools/fgt/cmdb/firewall/address.py | 8 ++++---- fotoobo/tools/fgt/cmdb/firewall/addrgrp.py | 8 ++++---- fotoobo/tools/fgt/cmdb/firewall/service_custom.py | 8 ++++---- fotoobo/tools/fgt/cmdb/firewall/service_group.py | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/fotoobo/tools/fgt/cmdb/firewall/address.py b/fotoobo/tools/fgt/cmdb/firewall/address.py index 2af439a..113cfe1 100644 --- a/fotoobo/tools/fgt/cmdb/firewall/address.py +++ b/fotoobo/tools/fgt/cmdb/firewall/address.py @@ -1,7 +1,7 @@ """FortiGate CMDB firewall address module""" from pathlib import Path -from typing import Any +from typing import Any, Dict, List from fotoobo.fortinet.fortigate import FortiGate from fotoobo.helpers.config import config @@ -11,14 +11,14 @@ def get_cmdb_firewall_address( host: str, name: str, vdom: str, output_file: str -) -> Result[list[Any]]: +) -> Result[List[Any]]: """Get the firewall address object(s) The FortiGate api endpoint is: /cmdb/firewall/address """ inventory = Inventory(config.inventory_file) fgt: FortiGate = inventory.get_item(host, "fortigate") - result = Result[list[Any]]() + result = Result[List[Any]]() address_list = fgt.api_get(url=f"/cmdb/firewall/address/{name}", vdom=vdom) result.push_result(key=host, data=address_list) @@ -32,7 +32,7 @@ def get_cmdb_firewall_address( for vd in address_list: for asset in vd["results"]: - data: dict[str, str] = { + data: Dict[str, str] = { "name": asset["name"], "vdom": vd["vdom"], "type": asset["type"], diff --git a/fotoobo/tools/fgt/cmdb/firewall/addrgrp.py b/fotoobo/tools/fgt/cmdb/firewall/addrgrp.py index d94465f..620c953 100644 --- a/fotoobo/tools/fgt/cmdb/firewall/addrgrp.py +++ b/fotoobo/tools/fgt/cmdb/firewall/addrgrp.py @@ -1,7 +1,7 @@ """FortiGate CMDB firewall addrgrp module""" from pathlib import Path -from typing import Any +from typing import Any, Dict, List from fotoobo.fortinet.fortigate import FortiGate from fotoobo.helpers.config import config @@ -11,14 +11,14 @@ def get_cmdb_firewall_addrgrp( host: str, name: str, vdom: str, output_file: str -) -> Result[list[Any]]: +) -> Result[List[Any]]: """Get the firewall address group object(s) The FortiGate api endpoint is: /cmdb/firewall/addrgrp """ inventory = Inventory(config.inventory_file) fgt: FortiGate = inventory.get_item(host, "fortigate") - result = Result[list[Any]]() + result = Result[List[Any]]() addrgrp_list = fgt.api_get(url=f"/cmdb/firewall/addrgrp/{name}", vdom=vdom) @@ -31,7 +31,7 @@ def get_cmdb_firewall_addrgrp( for vd in addrgrp_list: for asset in vd["results"]: # print(asset) - data: dict[str, str] = { + data: Dict[str, str] = { "name": asset["name"], "vdom": vd["vdom"], "content": "\n".join(_["name"] for _ in asset["member"]), diff --git a/fotoobo/tools/fgt/cmdb/firewall/service_custom.py b/fotoobo/tools/fgt/cmdb/firewall/service_custom.py index 3a08467..32e799d 100644 --- a/fotoobo/tools/fgt/cmdb/firewall/service_custom.py +++ b/fotoobo/tools/fgt/cmdb/firewall/service_custom.py @@ -1,7 +1,7 @@ """FortiGate CMDB firewall service custom module""" from pathlib import Path -from typing import Any +from typing import Any, Dict, List from fotoobo.fortinet.fortigate import FortiGate from fotoobo.helpers.config import config @@ -11,14 +11,14 @@ def get_cmdb_firewall_service_custom( host: str, name: str, vdom: str, output_file: str -) -> Result[list[Any]]: +) -> Result[List[Any]]: """Get the firewall service custom object(s) The FortiGate api endpoint is: /cmdb/firewall.service/custom """ inventory = Inventory(config.inventory_file) fgt: FortiGate = inventory.get_item(host, "fortigate") - result = Result[list[Any]]() + result = Result[List[Any]]() service_custom_list = fgt.api_get(url=f"/cmdb/firewall.service/custom/{name}", vdom=vdom) @@ -31,7 +31,7 @@ def get_cmdb_firewall_service_custom( for vd in service_custom_list: for asset in vd["results"]: - data: dict[str, str] = { + data: Dict[str, str] = { "name": asset["name"], "vdom": vd["vdom"], "protocol": asset["protocol"], diff --git a/fotoobo/tools/fgt/cmdb/firewall/service_group.py b/fotoobo/tools/fgt/cmdb/firewall/service_group.py index 24a8cc8..1dcee11 100644 --- a/fotoobo/tools/fgt/cmdb/firewall/service_group.py +++ b/fotoobo/tools/fgt/cmdb/firewall/service_group.py @@ -1,7 +1,7 @@ """FortiGate CMDB firewall service group module""" from pathlib import Path -from typing import Any +from typing import Any, Dict, List from fotoobo.fortinet.fortigate import FortiGate from fotoobo.helpers.config import config @@ -11,14 +11,14 @@ def get_cmdb_firewall_service_group( host: str, name: str, vdom: str, output_file: str -) -> Result[list[Any]]: +) -> Result[List[Any]]: """Get the firewall service group object(s) The FortiGate api endpoint is: /cmdb/firewall.service/group """ inventory = Inventory(config.inventory_file) fgt: FortiGate = inventory.get_item(host, "fortigate") - result = Result[list[Any]]() + result = Result[List[Any]]() service_group_list = fgt.api_get(url=f"/cmdb/firewall/addrgrp/{name}", vdom=vdom) @@ -30,7 +30,7 @@ def get_cmdb_firewall_service_group( if service_group_list: for vd in service_group_list: for asset in vd["results"]: - data: dict[str, str] = { + data: Dict[str, str] = { "name": asset["name"], "vdom": vd["vdom"], "content": "\n".join(_["name"] for _ in asset["member"]), From e4975592218688f0242f74e2e1640b77e3b98690 Mon Sep 17 00:00:00 2001 From: Patrik Spiess Date: Mon, 13 Jan 2025 16:06:09 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20Fix=20typing=20for?= =?UTF-8?q?=20Python3.8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fotoobo/fortinet/fortigate.py | 6 +-- fotoobo/fortinet/fortimanager.py | 70 ++++++++++++++--------------- tests/fortinet/test_fortimanager.py | 34 +++++++------- 3 files changed, 55 insertions(+), 55 deletions(-) diff --git a/fotoobo/fortinet/fortigate.py b/fotoobo/fortinet/fortigate.py index 957fffd..a928aa0 100644 --- a/fotoobo/fortinet/fortigate.py +++ b/fotoobo/fortinet/fortigate.py @@ -3,7 +3,7 @@ """ import logging -from typing import Any, Dict, Optional +from typing import Any, Dict, List, Optional import requests @@ -70,7 +70,7 @@ def api( # pylint: disable=too-many-arguments method, url, payload=payload, params=params, timeout=timeout, headers=headers ) - def api_get(self, url: str, vdom: str = "*", timeout: Optional[float] = None) -> list[Any]: + def api_get(self, url: str, vdom: str = "*", timeout: Optional[float] = None) -> List[Any]: """Low level GET request to a FortiGate. This gets the response from a single API request to a FortiGate and returns it as a fotoobo @@ -86,7 +86,7 @@ def api_get(self, url: str, vdom: str = "*", timeout: Optional[float] = None) -> """ params = {"vdom": vdom} response = self.api(method="get", url=url, params=params, timeout=timeout) - data: list[Any] = ( + data: List[Any] = ( [response.json()] if isinstance(response.json(), dict) else response.json() ) # this is to listify the data from the response diff --git a/fotoobo/fortinet/fortimanager.py b/fotoobo/fortinet/fortimanager.py index 1b06990..8575c3f 100644 --- a/fotoobo/fortinet/fortimanager.py +++ b/fotoobo/fortinet/fortimanager.py @@ -84,7 +84,7 @@ def api_delete(self, url: str) -> requests.models.Response: return self.api("post", payload=payload) def api_get( - self, url: str, params: Optional[dict[str, Any]] = None, timeout: Optional[float] = None + self, url: str, params: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None ) -> requests.models.Response: """GET method for API requests @@ -193,7 +193,7 @@ def assign_all_objects(self, adoms: str, policy: str) -> int: return task_id - def delete_adom_address(self, adom: str, address: str, dry: bool = False) -> dict[str, Any]: + def delete_adom_address(self, adom: str, address: str, dry: bool = False) -> Dict[str, Any]: """ Delete an address from an ADOM in FortiManager @@ -205,7 +205,7 @@ def delete_adom_address(self, adom: str, address: str, dry: bool = False) -> dic Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} if not dry: url: str = f"/pm/config/adom/{adom}/obj/firewall/address/{address}" result = self.api_delete(url).json()["result"][0] @@ -215,7 +215,7 @@ def delete_adom_address(self, adom: str, address: str, dry: bool = False) -> dic return result - def delete_adom_address_group(self, adom: str, group: str, dry: bool = False) -> dict[str, Any]: + def delete_adom_address_group(self, adom: str, group: str, dry: bool = False) -> Dict[str, Any]: """ Delete an address group from an ADOM in FortiManager @@ -227,7 +227,7 @@ def delete_adom_address_group(self, adom: str, group: str, dry: bool = False) -> Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} if not dry: url: str = f"/pm/config/adom/{adom}/obj/firewall/addrgrp/{group}" result = self.api_delete(url).json()["result"][0] @@ -237,7 +237,7 @@ def delete_adom_address_group(self, adom: str, group: str, dry: bool = False) -> return result - def delete_adom_service(self, adom: str, service: str, dry: bool = False) -> dict[str, Any]: + def delete_adom_service(self, adom: str, service: str, dry: bool = False) -> Dict[str, Any]: """ Delete a service from an ADOM in FortiManager @@ -249,7 +249,7 @@ def delete_adom_service(self, adom: str, service: str, dry: bool = False) -> dic Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} if not dry: url: str = f"/pm/config/adom/{adom}/obj/firewall/service/custom/{service}" result = self.api_delete(url).json()["result"][0] @@ -259,7 +259,7 @@ def delete_adom_service(self, adom: str, service: str, dry: bool = False) -> dic return result - def delete_adom_service_group(self, adom: str, group: str, dry: bool = False) -> dict[str, Any]: + def delete_adom_service_group(self, adom: str, group: str, dry: bool = False) -> Dict[str, Any]: """ Delete a service group from an ADOM in FortiManager @@ -271,7 +271,7 @@ def delete_adom_service_group(self, adom: str, group: str, dry: bool = False) -> Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} if not dry: url: str = f"/pm/config/adom/{adom}/obj/firewall/service/group/{group}" result = self.api_delete(url).json()["result"][0] @@ -281,7 +281,7 @@ def delete_adom_service_group(self, adom: str, group: str, dry: bool = False) -> return result - def delete_global_address(self, address: str, dry: bool = False) -> dict[str, Any]: + def delete_global_address(self, address: str, dry: bool = False) -> Dict[str, Any]: """ Delete a global address from FortiManager @@ -306,7 +306,7 @@ def delete_global_address(self, address: str, dry: bool = False) -> dict[str, An Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} # Get the address object with 'scope member' information address_object = self.get_global_address(address, scope_member=True) @@ -353,7 +353,7 @@ def delete_global_address(self, address: str, dry: bool = False) -> dict[str, An return result - def delete_global_address_group(self, group: str, dry: bool = False) -> dict[str, Any]: + def delete_global_address_group(self, group: str, dry: bool = False) -> Dict[str, Any]: """ Delete a global address group from FortiManager @@ -378,7 +378,7 @@ def delete_global_address_group(self, group: str, dry: bool = False) -> dict[str Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} # Get the address group object with 'scope member' information address_group_object = self.get_global_address_group(group, scope_member=True) @@ -423,7 +423,7 @@ def delete_global_address_group(self, group: str, dry: bool = False) -> dict[str return result - def delete_global_service(self, service: str, dry: bool = False) -> dict[str, Any]: + def delete_global_service(self, service: str, dry: bool = False) -> Dict[str, Any]: """ Delete a global service from FortiManager @@ -448,7 +448,7 @@ def delete_global_service(self, service: str, dry: bool = False) -> dict[str, An Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} # Get the service object with 'scope member' information service_object = self.get_global_service(service, scope_member=True) @@ -493,7 +493,7 @@ def delete_global_service(self, service: str, dry: bool = False) -> dict[str, An return result - def delete_global_service_group(self, group: str, dry: bool = False) -> dict[str, Any]: + def delete_global_service_group(self, group: str, dry: bool = False) -> Dict[str, Any]: """ Delete a global service group from FortiManager @@ -518,7 +518,7 @@ def delete_global_service_group(self, group: str, dry: bool = False) -> dict[str Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} # Get the service group object with 'scope member' information service_group_object = self.get_global_service_group(group, scope_member=True) @@ -563,7 +563,7 @@ def delete_global_service_group(self, group: str, dry: bool = False) -> dict[str return result - def get_adoms(self, ignored_adoms: Optional[List[str]] = None) -> list[Any]: + def get_adoms(self, ignored_adoms: Optional[List[str]] = None) -> List[Any]: """ Get FortiManager ADOM list @@ -585,7 +585,7 @@ def get_adoms(self, ignored_adoms: Optional[List[str]] = None) -> list[Any]: return fmg_adoms - def get_global_address(self, address: str, scope_member: bool = False) -> dict[str, Any]: + def get_global_address(self, address: str, scope_member: bool = False) -> Dict[str, Any]: """ Get an address object from global ADOM @@ -596,7 +596,7 @@ def get_global_address(self, address: str, scope_member: bool = False) -> dict[s Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} url: str = f"/pm/config/global/obj/firewall/address/{address}" if scope_member: @@ -610,21 +610,21 @@ def get_global_address(self, address: str, scope_member: bool = False) -> dict[s return result - def get_global_addresses(self) -> dict[str, Any]: + def get_global_addresses(self) -> Dict[str, Any]: """ Get the global address database Returns: FortiManager result item """ - result: dict[str, Any] = self.api_get( + result: Dict[str, Any] = self.api_get( "/pm/config/global/obj/firewall/address", timeout=10, ).json()["result"][0] return result - def get_global_address_group(self, group: str, scope_member: bool = False) -> dict[str, Any]: + def get_global_address_group(self, group: str, scope_member: bool = False) -> Dict[str, Any]: """ Get an address group object from the global ADOM @@ -635,7 +635,7 @@ def get_global_address_group(self, group: str, scope_member: bool = False) -> di Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} url: str = f"/pm/config/global/obj/firewall/addrgrp/{group}" if scope_member: @@ -649,21 +649,21 @@ def get_global_address_group(self, group: str, scope_member: bool = False) -> di return result - def get_global_address_groups(self) -> dict[str, Any]: + def get_global_address_groups(self) -> Dict[str, Any]: """ Get the global address group database Returns: FortiManager result item """ - result: dict[str, Any] = self.api_get( + result: Dict[str, Any] = self.api_get( "/pm/config/global/obj/firewall/addrgrp", timeout=10, ).json()["result"][0] return result - def get_global_service(self, service: str, scope_member: bool = False) -> dict[str, Any]: + def get_global_service(self, service: str, scope_member: bool = False) -> Dict[str, Any]: """ Get a service object from global ADOM @@ -674,7 +674,7 @@ def get_global_service(self, service: str, scope_member: bool = False) -> dict[s Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} url: str = f"/pm/config/global/obj/firewall/service/custom/{service}" if scope_member: @@ -688,21 +688,21 @@ def get_global_service(self, service: str, scope_member: bool = False) -> dict[s return result - def get_global_services(self) -> dict[str, Any]: + def get_global_services(self) -> Dict[str, Any]: """ Get the global services database Returns: FortiManager result item """ - result: dict[str, Any] = self.api_get( + result: Dict[str, Any] = self.api_get( "/pm/config/global/obj/firewall/service/custom", timeout=10, ).json()["result"][0] return result - def get_global_service_group(self, group: str, scope_member: bool = False) -> dict[str, Any]: + def get_global_service_group(self, group: str, scope_member: bool = False) -> Dict[str, Any]: """ Get a service group object from the global ADOM @@ -713,7 +713,7 @@ def get_global_service_group(self, group: str, scope_member: bool = False) -> di Returns: FortiManager result item """ - result: dict[str, Any] = {} + result: Dict[str, Any] = {} url: str = f"/pm/config/global/obj/firewall/service/group/{group}" if scope_member: @@ -727,14 +727,14 @@ def get_global_service_group(self, group: str, scope_member: bool = False) -> di return result - def get_global_service_groups(self) -> dict[str, Any]: + def get_global_service_groups(self) -> Dict[str, Any]: """ Get the global network service group database Returns: FortiManager result item """ - result: dict[str, Any] = self.api_get( + result: Dict[str, Any] = self.api_get( "/pm/config/global/obj/firewall/service/group", timeout=10, ).json()["result"][0] @@ -859,7 +859,7 @@ def post(self, adom: str, payloads: Any) -> List[str]: payloads: One payload (Dict) or a list of payloads (List of Dict) Returns: - Amount of errors ocurred during the set command + Amount of errors occurred during the set command """ # if payload is a dict convert it to a list with one dict in it. if isinstance(payloads, dict): diff --git a/tests/fortinet/test_fortimanager.py b/tests/fortinet/test_fortimanager.py index 812c471..bb49152 100644 --- a/tests/fortinet/test_fortimanager.py +++ b/tests/fortinet/test_fortimanager.py @@ -4,7 +4,7 @@ # pylint: disable=no-member, too-many-lines # mypy: disable-error-code=attr-defined -from typing import Any +from typing import Any, Dict, List from unittest.mock import MagicMock import pytest @@ -362,9 +362,9 @@ def test_delete_adom_service_group_dry() -> None: ), ) def test_delete_global_address( - get_global_address_data: dict[str, Any], - get_global_address_status: dict[str, Any], - delete_adom_address_status: dict[str, Any], + get_global_address_data: Dict[str, Any], + get_global_address_status: Dict[str, Any], + delete_adom_address_status: Dict[str, Any], monkeypatch: MonkeyPatch, ) -> None: """Test fmg delete_global_address""" @@ -416,9 +416,9 @@ def test_delete_global_address_dry() -> None: ), ) def test_delete_global_address_group( - get_global_address_group_data: dict[str, Any], - get_global_address_group_status: dict[str, Any], - delete_adom_address_group_status: dict[str, Any], + get_global_address_group_data: Dict[str, Any], + get_global_address_group_status: Dict[str, Any], + delete_adom_address_group_status: Dict[str, Any], monkeypatch: MonkeyPatch, ) -> None: """Test fmg delete_global_address_group""" @@ -470,9 +470,9 @@ def test_delete_global_address_group_dry() -> None: ), ) def test_delete_global_service( - get_global_service_data: dict[str, Any], - get_global_service_status: dict[str, Any], - delete_adom_service_status: dict[str, Any], + get_global_service_data: Dict[str, Any], + get_global_service_status: Dict[str, Any], + delete_adom_service_status: Dict[str, Any], monkeypatch: MonkeyPatch, ) -> None: """Test fmg delete_global_service""" @@ -524,9 +524,9 @@ def test_delete_global_service_dry() -> None: ), ) def test_delete_global_service_group( - get_global_service_group_data: dict[str, Any], - get_global_service_group_status: dict[str, Any], - delete_adom_service_group_status: dict[str, Any], + get_global_service_group_data: Dict[str, Any], + get_global_service_group_status: Dict[str, Any], + delete_adom_service_group_status: Dict[str, Any], monkeypatch: MonkeyPatch, ) -> None: """Test fmg delete_global_service_group""" @@ -599,7 +599,7 @@ def test_get_global_address(scope_member: bool) -> None: """Test fmg get_global_address""" fmg = FortiManager("host", "", "") assert fmg.get_global_address("dummy", scope_member=scope_member)["status"]["code"] == 0 - expected_call: list[Any] = ["/pm/config/global/obj/firewall/address/dummy"] + expected_call: List[Any] = ["/pm/config/global/obj/firewall/address/dummy"] if scope_member: expected_call.append({"option": ["scope member"]}) @@ -629,7 +629,7 @@ def test_get_global_address_group(scope_member: bool) -> None: assert ( fmg.get_global_address_group("dummy", scope_member=scope_member)["status"]["code"] == 0 ) - expected_call: list[Any] = ["/pm/config/global/obj/firewall/addrgrp/dummy"] + expected_call: List[Any] = ["/pm/config/global/obj/firewall/addrgrp/dummy"] if scope_member: expected_call.append({"option": ["scope member"]}) FortiManager.api_get.assert_called_with(*expected_call) @@ -659,7 +659,7 @@ def test_get_global_service(scope_member: bool) -> None: """Test fmg get_global_service""" fmg = FortiManager("host", "", "") assert fmg.get_global_service("dummy", scope_member=scope_member)["status"]["code"] == 0 - expected_call: list[Any] = ["/pm/config/global/obj/firewall/service/custom/dummy"] + expected_call: List[Any] = ["/pm/config/global/obj/firewall/service/custom/dummy"] if scope_member: expected_call.append({"option": ["scope member"]}) FortiManager.api_get.assert_called_with(*expected_call) @@ -688,7 +688,7 @@ def test_get_global_service_group(scope_member: bool) -> None: assert ( fmg.get_global_service_group("dummy", scope_member=scope_member)["status"]["code"] == 0 ) - expected_call: list[Any] = ["/pm/config/global/obj/firewall/service/group/dummy"] + expected_call: List[Any] = ["/pm/config/global/obj/firewall/service/group/dummy"] if scope_member: expected_call.append({"option": ["scope member"]}) FortiManager.api_get.assert_called_with(*expected_call) From de78a562cacae6854b3a1d91fc1e01a05fa14b9f Mon Sep 17 00:00:00 2001 From: Patrik Spiess Date: Mon, 13 Jan 2025 16:09:14 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9D=20Update=20WHATSNEW?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WHATSNEW.md | 1 + 1 file changed, 1 insertion(+) diff --git a/WHATSNEW.md b/WHATSNEW.md index 4515f97..969c2a6 100644 --- a/WHATSNEW.md +++ b/WHATSNEW.md @@ -10,6 +10,7 @@ ### Changed +- Fix some typing issues for Python3.8 - Optimize imports in CLI module - Upgrade requests, jinja and pygount due to security issues and bugs