From 1ec1da9ac3af5a5c3fc9dfaab85849e0fe6f9030 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Apr 2021 04:15:16 +0000 Subject: [PATCH 1/3] Bump black from 20.8b1 to 21.4b0 Bumps [black](https://github.com/psf/black) from 20.8b1 to 21.4b0. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/master/CHANGES.md) - [Commits](https://github.com/psf/black/commits) Signed-off-by: dependabot[bot] --- poetry.lock | 14 ++++++++------ pyproject.toml | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/poetry.lock b/poetry.lock index aba89e77..64162500 100644 --- a/poetry.lock +++ b/poetry.lock @@ -74,11 +74,11 @@ typecheck = ["mypy"] [[package]] name = "black" -version = "20.8b1" +version = "21.4b0" description = "The uncompromising code formatter." category = "dev" optional = false -python-versions = ">=3.6" +python-versions = ">=3.6.2" [package.dependencies] appdirs = "*" @@ -87,12 +87,13 @@ mypy-extensions = ">=0.4.3" pathspec = ">=0.6,<1" regex = ">=2020.1.8" toml = ">=0.10.1" -typed-ast = ">=1.4.0" -typing-extensions = ">=3.7.4" +typed-ast = {version = ">=1.4.2", markers = "python_version < \"3.8\""} +typing-extensions = {version = ">=3.7.4", markers = "python_version < \"3.8\""} [package.extras] colorama = ["colorama (>=0.4.3)"] d = ["aiohttp (>=3.3.2)", "aiohttp-cors"] +python2 = ["typed-ast (>=1.4.2)"] [[package]] name = "certifi" @@ -494,7 +495,7 @@ python-versions = "*" [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "43c0e4251c20eaa8142b19d89314e776bf864c0e8974f2eab7c9a5aa590a5e3f" +content-hash = "68af37b4dfd3cb972a18cfb441fc25e2932991e275f47924b41010f4a80c6b1b" [metadata.files] appdirs = [ @@ -527,7 +528,8 @@ bcrypt = [ {file = "bcrypt-3.2.0.tar.gz", hash = "sha256:5b93c1726e50a93a033c36e5ca7fdcd29a5c7395af50a6892f5d9e7c6cfbfb29"}, ] black = [ - {file = "black-20.8b1.tar.gz", hash = "sha256:1c02557aa099101b9d21496f8a914e9ed2222ef70336404eeeac8edba836fbea"}, + {file = "black-21.4b0-py3-none-any.whl", hash = "sha256:2db7040bbbbaa46247bfcc05c6efdebd7ebe50c1c3ca745ca6e0f6776438c96c"}, + {file = "black-21.4b0.tar.gz", hash = "sha256:915d916c48646dbe8040d5265cff7111421a60a3dfe7f7e07273176a57c24a34"}, ] certifi = [ {file = "certifi-2020.12.5-py2.py3-none-any.whl", hash = "sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"}, diff --git a/pyproject.toml b/pyproject.toml index e8cc7ba8..4859cd24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ pylint = "^2.7.4" rope = "^0.19.0" autohooks-plugin-pylint = "^1.2.0" autohooks-plugin-black = {version = "^1.2.0", python = "^3.7"} -black = {version = "20.8b1", python = "^3.7"} +black = {version = "21.4b0", python = "^3.7"} pontos = "^21.3.0" From ded85ae4d9c3824568a0cb8957503d7dbe68bceb Mon Sep 17 00:00:00 2001 From: Juan Jose Nicola Date: Mon, 26 Apr 2021 02:38:34 -0500 Subject: [PATCH 2/3] Fix conflicts and format with new black --- ospd_openvas/daemon.py | 14 ++--- ospd_openvas/db.py | 10 ++-- ospd_openvas/preferencehandler.py | 14 ++--- ospd_openvas/vthelper.py | 4 +- poetry.lock | 91 +++++++++++++++---------------- 5 files changed, 64 insertions(+), 69 deletions(-) diff --git a/ospd_openvas/daemon.py b/ospd_openvas/daemon.py index e14bdb1d..8191bd2b 100644 --- a/ospd_openvas/daemon.py +++ b/ospd_openvas/daemon.py @@ -435,12 +435,12 @@ def get_filtered_vts_list(self, vts, vt_filter: str) -> Optional[List[str]]: class OSPDopenvas(OSPDaemon): - """ Class for ospd-openvas daemon. """ + """Class for ospd-openvas daemon.""" def __init__( self, *, niceness=None, lock_file_dir='/var/run/ospd', **kwargs ): - """ Initializes the ospd-openvas daemon's internal data. """ + """Initializes the ospd-openvas daemon's internal data.""" self.main_db = MainDB() self.nvti = NVTICache(self.main_db) @@ -916,7 +916,7 @@ def get_detection_vt_as_xml_str( @property def is_running_as_root(self) -> bool: - """ Check if it is running as root user.""" + """Check if it is running as root user.""" if self._is_running_as_root is not None: return self._is_running_as_root @@ -928,7 +928,7 @@ def is_running_as_root(self) -> bool: @property def sudo_available(self) -> bool: - """ Checks that sudo is available """ + """Checks that sudo is available""" if self._sudo_available is not None: return self._sudo_available @@ -1013,7 +1013,7 @@ def get_severity_score(self, vt_aux: dict) -> Optional[float]: return None def report_openvas_results(self, db: BaseDB, scan_id: str) -> bool: - """ Get all result entries from redis kb. """ + """Get all result entries from redis kb.""" vthelper = VtHelper(self.nvti) @@ -1247,7 +1247,7 @@ def stop_scan_cleanup( # pylint: disable=arguments-differ self.main_db.release_database(scan_db) def exec_scan(self, scan_id: str): - """ Starts the OpenVAS scanner for scan_id scan. """ + """Starts the OpenVAS scanner for scan_id scan.""" do_not_launch = False kbdb = self.main_db.get_new_kb_database() scan_prefs = PreferenceHandler( @@ -1384,7 +1384,7 @@ def exec_scan(self, scan_id: str): def main(): - """ OSP openvas main function. """ + """OSP openvas main function.""" daemon_main('OSPD - openvas', OSPDopenvas) diff --git a/ospd_openvas/db.py b/ospd_openvas/db.py index 509e52fd..41485a4e 100644 --- a/ospd_openvas/db.py +++ b/ospd_openvas/db.py @@ -402,7 +402,7 @@ def __init__(self, kbindex: int, ctx: Optional[RedisCtx] = None): self.index = kbindex def flush(self): - """ Flush the database """ + """Flush the database""" self.ctx.flushdb() @@ -470,7 +470,7 @@ def get_result(self) -> Optional[str]: return self._pop_list_items("internal/results") def get_status(self, openvas_scan_id: str) -> Optional[str]: - """ Return the status of the host scan """ + """Return the status of the host scan""" return self._get_single_item('internal/{}'.format(openvas_scan_id)) def __repr__(self): @@ -478,7 +478,7 @@ def __repr__(self): class ScanDB(BaseKbDB): - """ Database for a scanning a single host """ + """Database for a scanning a single host""" def select(self, kbindex: int) -> "ScanDB": """Select a redis kb. @@ -538,7 +538,7 @@ def remove_scan_database(self, scan_db: ScanDB): self._remove_list_item('internal/dbindex', scan_db.index) def target_is_finished(self, scan_id: str) -> bool: - """ Check if a target has finished. """ + """Check if a target has finished.""" status = self._get_single_item('internal/{}'.format(scan_id)) @@ -563,7 +563,7 @@ def get_scan_status(self) -> List: class MainDB(BaseDB): - """ Main Database """ + """Main Database""" DEFAULT_INDEX = 0 diff --git a/ospd_openvas/preferencehandler.py b/ospd_openvas/preferencehandler.py index 2f77fb52..e992914e 100644 --- a/ospd_openvas/preferencehandler.py +++ b/ospd_openvas/preferencehandler.py @@ -52,7 +52,7 @@ class AliveTest(IntEnum): - """ Alive Tests. """ + """Alive Tests.""" ALIVE_TEST_SCAN_CONFIG_DEFAULT = 0 ALIVE_TEST_TCP_ACK_SERVICE = 1 @@ -114,7 +114,7 @@ def prepare_scan_id_for_openvas(self): @property def target_options(self) -> Dict: - """ Return target options from Scan collection """ + """Return target options from Scan collection""" if self._target_options is not None: return self._target_options @@ -156,7 +156,7 @@ def _get_vts_in_groups( return vts_list def _get_vt_param_type(self, vt: Dict, vt_param_id: str) -> Optional[str]: - """ Return the type of the vt parameter from the vts dictionary. """ + """Return the type of the vt parameter from the vts dictionary.""" vt_params_list = vt.get("vt_params") if vt_params_list.get(vt_param_id): @@ -164,7 +164,7 @@ def _get_vt_param_type(self, vt: Dict, vt_param_id: str) -> Optional[str]: return None def _get_vt_param_name(self, vt: Dict, vt_param_id: str) -> Optional[str]: - """ Return the type of the vt parameter from the vts dictionary. """ + """Return the type of the vt parameter from the vts dictionary.""" vt_params_list = vt.get("vt_params") if vt_params_list.get(vt_param_id): @@ -210,7 +210,7 @@ def _process_vts( self, vts: Dict[str, Dict[str, str]], ) -> Tuple[List[str], Dict[str, str]]: - """ Add single VTs and their parameters. """ + """Add single VTs and their parameters.""" vts_list = [] vts_params = {} vtgroups = vts.pop('vt_groups') @@ -418,7 +418,7 @@ def build_alive_test_opt_as_prefs( return target_opt_prefs_list def prepare_alive_test_option_for_openvas(self): - """ Set alive test option. Overwrite the scan config settings.""" + """Set alive test option. Overwrite the scan config settings.""" settings = Openvas.get_settings() if settings and ( self.target_options.get('alive_test') @@ -499,7 +499,7 @@ def prepare_boreas_alive_test(self): self.kbdb.add_scan_preferences(self.scan_id, [pref]) def prepare_reverse_lookup_opt_for_openvas(self): - """ Set reverse lookup options in the kb""" + """Set reverse lookup options in the kb""" if self.target_options: items = [] _rev_lookup_only = int( diff --git a/ospd_openvas/vthelper.py b/ospd_openvas/vthelper.py index 4335a31d..092f67ec 100644 --- a/ospd_openvas/vthelper.py +++ b/ospd_openvas/vthelper.py @@ -157,7 +157,7 @@ def get_single_vt(self, vt_id: str, oids=None) -> Optional[Dict[str, any]]: def get_vt_iterator( self, vt_selection: List[str] = None, details: bool = True ) -> Iterator[Tuple[str, Dict]]: - """ Yield the vts from the Redis NVTicache. """ + """Yield the vts from the Redis NVTicache.""" oids = None if not vt_selection or details: @@ -174,7 +174,7 @@ def get_vt_iterator( yield (vt_id, vt) def calculate_vts_collection_hash(self) -> str: - """ Calculate the vts collection sha256 hash. """ + """Calculate the vts collection sha256 hash.""" m = sha256() # pylint: disable=invalid-name # for a reproducible hash calculation diff --git a/poetry.lock b/poetry.lock index 64162500..cab42f7d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -8,11 +8,11 @@ python-versions = "*" [[package]] name = "astroid" -version = "2.5.2" +version = "2.5.6" description = "An abstract syntax tree for Python with inference support." category = "dev" optional = false -python-versions = ">=3.6" +python-versions = "~=3.6" [package.dependencies] lazy-object-proxy = ">=1.4.0" @@ -269,7 +269,7 @@ psutil = "^5.7.2" type = "git" url = "https://github.com/greenbone/ospd.git" reference = "master" -resolved_reference = "aa3e3eddc22954958862b09a9ca704ca15d2d0c6" +resolved_reference = "1fcaa8eb20b7767d2e0dd66d8868529743847b57" [[package]] name = "packaging" @@ -311,7 +311,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "pontos" -version = "21.3.0" +version = "21.4.0" description = "Common utilities and tools maintained by Greenbone Networks" category = "dev" optional = false @@ -343,22 +343,19 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" [[package]] name = "pylint" -version = "2.7.4" +version = "2.8.1" description = "python code static checker" category = "dev" optional = false python-versions = "~=3.6" [package.dependencies] -astroid = ">=2.5.2,<2.7" +astroid = ">=2.5.6,<2.7" colorama = {version = "*", markers = "sys_platform == \"win32\""} isort = ">=4.2.5,<6" mccabe = ">=0.6,<0.7" toml = ">=0.7.1" -[package.extras] -docs = ["sphinx (==3.5.1)", "python-docs-theme (==2020.12)"] - [[package]] name = "pynacl" version = "1.4.0" @@ -457,7 +454,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "typed-ast" -version = "1.4.2" +version = "1.4.3" description = "a fork of Python 2 and 3 ast modules with type comment support" category = "dev" optional = false @@ -503,8 +500,8 @@ appdirs = [ {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, ] astroid = [ - {file = "astroid-2.5.2-py3-none-any.whl", hash = "sha256:cd80bf957c49765dce6d92c43163ff9d2abc43132ce64d4b1b47717c6d2522df"}, - {file = "astroid-2.5.2.tar.gz", hash = "sha256:6b0ed1af831570e500e2437625979eaa3b36011f66ddfc4ce930128610258ca9"}, + {file = "astroid-2.5.6-py3-none-any.whl", hash = "sha256:4db03ab5fc3340cf619dbc25e42c2cc3755154ce6009469766d7143d1fc2ee4e"}, + {file = "astroid-2.5.6.tar.gz", hash = "sha256:8a398dfce302c13f14bab13e2b14fe385d32b73f4e4853b9bdfb64598baa1975"}, ] autohooks = [ {file = "autohooks-21.3.0-py3-none-any.whl", hash = "sha256:7674ff73741825de83a5b3a5fb701528571810e8d67d3800f4d9167be43f1550"}, @@ -704,8 +701,8 @@ pathspec = [ {file = "pathspec-0.8.1.tar.gz", hash = "sha256:86379d6b86d75816baba717e64b1a3a3469deb93bb76d613c9ce79edc5cb68fd"}, ] pontos = [ - {file = "pontos-21.3.0-py3-none-any.whl", hash = "sha256:70731a5dc825b299209b1ccae6da3b8e2383cd03159ba0b12c3e563d655558d1"}, - {file = "pontos-21.3.0.tar.gz", hash = "sha256:3456f3727440ca74be437519b90da0a86c9d8d0305c3d5623da89e322785b0bc"}, + {file = "pontos-21.4.0-py3-none-any.whl", hash = "sha256:bc98903e164c6442e680700343251aa962f721cfb9802717bcffd372eb2b7b8d"}, + {file = "pontos-21.4.0.tar.gz", hash = "sha256:83390bf5b7f0cd13f84043a64dbbcb3ac8a2c3d7723e84d8e7fc66316e8cd1f1"}, ] psutil = [ {file = "psutil-5.8.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:0066a82f7b1b37d334e68697faba68e5ad5e858279fd6351c8ca6024e8d6ba64"}, @@ -742,8 +739,8 @@ pycparser = [ {file = "pycparser-2.20.tar.gz", hash = "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0"}, ] pylint = [ - {file = "pylint-2.7.4-py3-none-any.whl", hash = "sha256:209d712ec870a0182df034ae19f347e725c1e615b2269519ab58a35b3fcbbe7a"}, - {file = "pylint-2.7.4.tar.gz", hash = "sha256:bd38914c7731cdc518634a8d3c5585951302b6e2b6de60fbb3f7a0220e21eeee"}, + {file = "pylint-2.8.1-py3-none-any.whl", hash = "sha256:4236b7284853b779a8add49aca287a5899245894995c5591d2b5839a32482330"}, + {file = "pylint-2.8.1.tar.gz", hash = "sha256:ad1bff19c46bfc6d2aeba4de5f76570d253df4915d2043ba61dc6a96233c4bd6"}, ] pynacl = [ {file = "PyNaCl-1.4.0-cp27-cp27m-macosx_10_10_x86_64.whl", hash = "sha256:ea6841bc3a76fa4942ce00f3bda7d436fda21e2d91602b9e21b7ca9ecab8f3ff"}, @@ -753,8 +750,6 @@ pynacl = [ {file = "PyNaCl-1.4.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:7757ae33dae81c300487591c68790dfb5145c7d03324000433d9a2c141f82af7"}, {file = "PyNaCl-1.4.0-cp35-abi3-macosx_10_10_x86_64.whl", hash = "sha256:757250ddb3bff1eecd7e41e65f7f833a8405fede0194319f87899690624f2122"}, {file = "PyNaCl-1.4.0-cp35-abi3-manylinux1_x86_64.whl", hash = "sha256:30f9b96db44e09b3304f9ea95079b1b7316b2b4f3744fe3aaecccd95d547063d"}, - {file = "PyNaCl-1.4.0-cp35-abi3-win32.whl", hash = "sha256:4e10569f8cbed81cb7526ae137049759d2a8d57726d52c1a000a3ce366779634"}, - {file = "PyNaCl-1.4.0-cp35-abi3-win_amd64.whl", hash = "sha256:c914f78da4953b33d4685e3cdc7ce63401247a21425c16a39760e282075ac4a6"}, {file = "PyNaCl-1.4.0-cp35-cp35m-win32.whl", hash = "sha256:06cbb4d9b2c4bd3c8dc0d267416aaed79906e7b33f114ddbf0911969794b1cc4"}, {file = "PyNaCl-1.4.0-cp35-cp35m-win_amd64.whl", hash = "sha256:511d269ee845037b95c9781aa702f90ccc36036f95d0f31373a6a79bd8242e25"}, {file = "PyNaCl-1.4.0-cp36-cp36m-win32.whl", hash = "sha256:11335f09060af52c97137d4ac54285bcb7df0cef29014a1a4efe64ac065434c4"}, @@ -836,36 +831,36 @@ tomlkit = [ {file = "tomlkit-0.7.0.tar.gz", hash = "sha256:ac57f29693fab3e309ea789252fcce3061e19110085aa31af5446ca749325618"}, ] typed-ast = [ - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:7703620125e4fb79b64aa52427ec192822e9f45d37d4b6625ab37ef403e1df70"}, - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c9aadc4924d4b5799112837b226160428524a9a45f830e0d0f184b19e4090487"}, - {file = "typed_ast-1.4.2-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:9ec45db0c766f196ae629e509f059ff05fc3148f9ffd28f3cfe75d4afb485412"}, - {file = "typed_ast-1.4.2-cp35-cp35m-win32.whl", hash = "sha256:85f95aa97a35bdb2f2f7d10ec5bbdac0aeb9dafdaf88e17492da0504de2e6400"}, - {file = "typed_ast-1.4.2-cp35-cp35m-win_amd64.whl", hash = "sha256:9044ef2df88d7f33692ae3f18d3be63dec69c4fb1b5a4a9ac950f9b4ba571606"}, - {file = "typed_ast-1.4.2-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:c1c876fd795b36126f773db9cbb393f19808edd2637e00fd6caba0e25f2c7b64"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:5dcfc2e264bd8a1db8b11a892bd1647154ce03eeba94b461effe68790d8b8e07"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:8db0e856712f79c45956da0c9a40ca4246abc3485ae0d7ecc86a20f5e4c09abc"}, - {file = "typed_ast-1.4.2-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:d003156bb6a59cda9050e983441b7fa2487f7800d76bdc065566b7d728b4581a"}, - {file = "typed_ast-1.4.2-cp36-cp36m-win32.whl", hash = "sha256:4c790331247081ea7c632a76d5b2a265e6d325ecd3179d06e9cf8d46d90dd151"}, - {file = "typed_ast-1.4.2-cp36-cp36m-win_amd64.whl", hash = "sha256:d175297e9533d8d37437abc14e8a83cbc68af93cc9c1c59c2c292ec59a0697a3"}, - {file = "typed_ast-1.4.2-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:cf54cfa843f297991b7388c281cb3855d911137223c6b6d2dd82a47ae5125a41"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:b4fcdcfa302538f70929eb7b392f536a237cbe2ed9cba88e3bf5027b39f5f77f"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:987f15737aba2ab5f3928c617ccf1ce412e2e321c77ab16ca5a293e7bbffd581"}, - {file = "typed_ast-1.4.2-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:37f48d46d733d57cc70fd5f30572d11ab8ed92da6e6b28e024e4a3edfb456e37"}, - {file = "typed_ast-1.4.2-cp37-cp37m-win32.whl", hash = "sha256:36d829b31ab67d6fcb30e185ec996e1f72b892255a745d3a82138c97d21ed1cd"}, - {file = "typed_ast-1.4.2-cp37-cp37m-win_amd64.whl", hash = "sha256:8368f83e93c7156ccd40e49a783a6a6850ca25b556c0fa0240ed0f659d2fe496"}, - {file = "typed_ast-1.4.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:963c80b583b0661918718b095e02303d8078950b26cc00b5e5ea9ababe0de1fc"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux1_i686.whl", hash = "sha256:e683e409e5c45d5c9082dc1daf13f6374300806240719f95dc783d1fc942af10"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:84aa6223d71012c68d577c83f4e7db50d11d6b1399a9c779046d75e24bed74ea"}, - {file = "typed_ast-1.4.2-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:a38878a223bdd37c9709d07cd357bb79f4c760b29210e14ad0fb395294583787"}, - {file = "typed_ast-1.4.2-cp38-cp38-win32.whl", hash = "sha256:a2c927c49f2029291fbabd673d51a2180038f8cd5a5b2f290f78c4516be48be2"}, - {file = "typed_ast-1.4.2-cp38-cp38-win_amd64.whl", hash = "sha256:c0c74e5579af4b977c8b932f40a5464764b2f86681327410aa028a22d2f54937"}, - {file = "typed_ast-1.4.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:07d49388d5bf7e863f7fa2f124b1b1d89d8aa0e2f7812faff0a5658c01c59aa1"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux1_i686.whl", hash = "sha256:240296b27397e4e37874abb1df2a608a92df85cf3e2a04d0d4d61055c8305ba6"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:d746a437cdbca200622385305aedd9aef68e8a645e385cc483bdc5e488f07166"}, - {file = "typed_ast-1.4.2-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:14bf1522cdee369e8f5581238edac09150c765ec1cb33615855889cf33dcb92d"}, - {file = "typed_ast-1.4.2-cp39-cp39-win32.whl", hash = "sha256:cc7b98bf58167b7f2db91a4327da24fb93368838eb84a44c472283778fc2446b"}, - {file = "typed_ast-1.4.2-cp39-cp39-win_amd64.whl", hash = "sha256:7147e2a76c75f0f64c4319886e7639e490fee87c9d25cb1d4faef1d8cf83a440"}, - {file = "typed_ast-1.4.2.tar.gz", hash = "sha256:9fc0b3cb5d1720e7141d103cf4819aea239f7d136acf9ee4a69b047b7986175a"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:2068531575a125b87a41802130fa7e29f26c09a2833fea68d9a40cf33902eba6"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:c907f561b1e83e93fad565bac5ba9c22d96a54e7ea0267c708bffe863cbe4075"}, + {file = "typed_ast-1.4.3-cp35-cp35m-manylinux2014_aarch64.whl", hash = "sha256:1b3ead4a96c9101bef08f9f7d1217c096f31667617b58de957f690c92378b528"}, + {file = "typed_ast-1.4.3-cp35-cp35m-win32.whl", hash = "sha256:dde816ca9dac1d9c01dd504ea5967821606f02e510438120091b84e852367428"}, + {file = "typed_ast-1.4.3-cp35-cp35m-win_amd64.whl", hash = "sha256:777a26c84bea6cd934422ac2e3b78863a37017618b6e5c08f92ef69853e765d3"}, + {file = "typed_ast-1.4.3-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:f8afcf15cc511ada719a88e013cec87c11aff7b91f019295eb4530f96fe5ef2f"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_i686.whl", hash = "sha256:52b1eb8c83f178ab787f3a4283f68258525f8d70f778a2f6dd54d3b5e5fb4341"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:01ae5f73431d21eead5015997ab41afa53aa1fbe252f9da060be5dad2c730ace"}, + {file = "typed_ast-1.4.3-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:c190f0899e9f9f8b6b7863debfb739abcb21a5c054f911ca3596d12b8a4c4c7f"}, + {file = "typed_ast-1.4.3-cp36-cp36m-win32.whl", hash = "sha256:398e44cd480f4d2b7ee8d98385ca104e35c81525dd98c519acff1b79bdaac363"}, + {file = "typed_ast-1.4.3-cp36-cp36m-win_amd64.whl", hash = "sha256:bff6ad71c81b3bba8fa35f0f1921fb24ff4476235a6e94a26ada2e54370e6da7"}, + {file = "typed_ast-1.4.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0fb71b8c643187d7492c1f8352f2c15b4c4af3f6338f21681d3681b3dc31a266"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_i686.whl", hash = "sha256:760ad187b1041a154f0e4d0f6aae3e40fdb51d6de16e5c99aedadd9246450e9e"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:5feca99c17af94057417d744607b82dd0a664fd5e4ca98061480fd8b14b18d04"}, + {file = "typed_ast-1.4.3-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:95431a26309a21874005845c21118c83991c63ea800dd44843e42a916aec5899"}, + {file = "typed_ast-1.4.3-cp37-cp37m-win32.whl", hash = "sha256:aee0c1256be6c07bd3e1263ff920c325b59849dc95392a05f258bb9b259cf39c"}, + {file = "typed_ast-1.4.3-cp37-cp37m-win_amd64.whl", hash = "sha256:9ad2c92ec681e02baf81fdfa056fe0d818645efa9af1f1cd5fd6f1bd2bdfd805"}, + {file = "typed_ast-1.4.3-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:b36b4f3920103a25e1d5d024d155c504080959582b928e91cb608a65c3a49e1a"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_i686.whl", hash = "sha256:067a74454df670dcaa4e59349a2e5c81e567d8d65458d480a5b3dfecec08c5ff"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:7538e495704e2ccda9b234b82423a4038f324f3a10c43bc088a1636180f11a41"}, + {file = "typed_ast-1.4.3-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:af3d4a73793725138d6b334d9d247ce7e5f084d96284ed23f22ee626a7b88e39"}, + {file = "typed_ast-1.4.3-cp38-cp38-win32.whl", hash = "sha256:f2362f3cb0f3172c42938946dbc5b7843c2a28aec307c49100c8b38764eb6927"}, + {file = "typed_ast-1.4.3-cp38-cp38-win_amd64.whl", hash = "sha256:dd4a21253f42b8d2b48410cb31fe501d32f8b9fbeb1f55063ad102fe9c425e40"}, + {file = "typed_ast-1.4.3-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:f328adcfebed9f11301eaedfa48e15bdece9b519fb27e6a8c01aa52a17ec31b3"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_i686.whl", hash = "sha256:2c726c276d09fc5c414693a2de063f521052d9ea7c240ce553316f70656c84d4"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:cae53c389825d3b46fb37538441f75d6aecc4174f615d048321b716df2757fb0"}, + {file = "typed_ast-1.4.3-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:b9574c6f03f685070d859e75c7f9eeca02d6933273b5e69572e5ff9d5e3931c3"}, + {file = "typed_ast-1.4.3-cp39-cp39-win32.whl", hash = "sha256:209596a4ec71d990d71d5e0d312ac935d86930e6eecff6ccc7007fe54d703808"}, + {file = "typed_ast-1.4.3-cp39-cp39-win_amd64.whl", hash = "sha256:9c6d1a54552b5330bc657b7ef0eae25d00ba7ffe85d9ea8ae6540d2197a3788c"}, + {file = "typed_ast-1.4.3.tar.gz", hash = "sha256:fb1bbeac803adea29cedd70781399c99138358c26d05fcbd23c13016b7f5ec65"}, ] typing-extensions = [ {file = "typing_extensions-3.7.4.3-py2-none-any.whl", hash = "sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"}, From de5dec4ac0f55abc6cd8ad4adf4a06eb2078d107 Mon Sep 17 00:00:00 2001 From: Juan Jose Nicola Date: Mon, 26 Apr 2021 02:38:34 -0500 Subject: [PATCH 3/3] Fix conflicts and format with new black --- ospd_openvas/daemon.py | 14 +++++++------- ospd_openvas/db.py | 10 +++++----- ospd_openvas/preferencehandler.py | 14 +++++++------- ospd_openvas/vthelper.py | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ospd_openvas/daemon.py b/ospd_openvas/daemon.py index e14bdb1d..8191bd2b 100644 --- a/ospd_openvas/daemon.py +++ b/ospd_openvas/daemon.py @@ -435,12 +435,12 @@ def get_filtered_vts_list(self, vts, vt_filter: str) -> Optional[List[str]]: class OSPDopenvas(OSPDaemon): - """ Class for ospd-openvas daemon. """ + """Class for ospd-openvas daemon.""" def __init__( self, *, niceness=None, lock_file_dir='/var/run/ospd', **kwargs ): - """ Initializes the ospd-openvas daemon's internal data. """ + """Initializes the ospd-openvas daemon's internal data.""" self.main_db = MainDB() self.nvti = NVTICache(self.main_db) @@ -916,7 +916,7 @@ def get_detection_vt_as_xml_str( @property def is_running_as_root(self) -> bool: - """ Check if it is running as root user.""" + """Check if it is running as root user.""" if self._is_running_as_root is not None: return self._is_running_as_root @@ -928,7 +928,7 @@ def is_running_as_root(self) -> bool: @property def sudo_available(self) -> bool: - """ Checks that sudo is available """ + """Checks that sudo is available""" if self._sudo_available is not None: return self._sudo_available @@ -1013,7 +1013,7 @@ def get_severity_score(self, vt_aux: dict) -> Optional[float]: return None def report_openvas_results(self, db: BaseDB, scan_id: str) -> bool: - """ Get all result entries from redis kb. """ + """Get all result entries from redis kb.""" vthelper = VtHelper(self.nvti) @@ -1247,7 +1247,7 @@ def stop_scan_cleanup( # pylint: disable=arguments-differ self.main_db.release_database(scan_db) def exec_scan(self, scan_id: str): - """ Starts the OpenVAS scanner for scan_id scan. """ + """Starts the OpenVAS scanner for scan_id scan.""" do_not_launch = False kbdb = self.main_db.get_new_kb_database() scan_prefs = PreferenceHandler( @@ -1384,7 +1384,7 @@ def exec_scan(self, scan_id: str): def main(): - """ OSP openvas main function. """ + """OSP openvas main function.""" daemon_main('OSPD - openvas', OSPDopenvas) diff --git a/ospd_openvas/db.py b/ospd_openvas/db.py index 509e52fd..41485a4e 100644 --- a/ospd_openvas/db.py +++ b/ospd_openvas/db.py @@ -402,7 +402,7 @@ def __init__(self, kbindex: int, ctx: Optional[RedisCtx] = None): self.index = kbindex def flush(self): - """ Flush the database """ + """Flush the database""" self.ctx.flushdb() @@ -470,7 +470,7 @@ def get_result(self) -> Optional[str]: return self._pop_list_items("internal/results") def get_status(self, openvas_scan_id: str) -> Optional[str]: - """ Return the status of the host scan """ + """Return the status of the host scan""" return self._get_single_item('internal/{}'.format(openvas_scan_id)) def __repr__(self): @@ -478,7 +478,7 @@ def __repr__(self): class ScanDB(BaseKbDB): - """ Database for a scanning a single host """ + """Database for a scanning a single host""" def select(self, kbindex: int) -> "ScanDB": """Select a redis kb. @@ -538,7 +538,7 @@ def remove_scan_database(self, scan_db: ScanDB): self._remove_list_item('internal/dbindex', scan_db.index) def target_is_finished(self, scan_id: str) -> bool: - """ Check if a target has finished. """ + """Check if a target has finished.""" status = self._get_single_item('internal/{}'.format(scan_id)) @@ -563,7 +563,7 @@ def get_scan_status(self) -> List: class MainDB(BaseDB): - """ Main Database """ + """Main Database""" DEFAULT_INDEX = 0 diff --git a/ospd_openvas/preferencehandler.py b/ospd_openvas/preferencehandler.py index 2f77fb52..e992914e 100644 --- a/ospd_openvas/preferencehandler.py +++ b/ospd_openvas/preferencehandler.py @@ -52,7 +52,7 @@ class AliveTest(IntEnum): - """ Alive Tests. """ + """Alive Tests.""" ALIVE_TEST_SCAN_CONFIG_DEFAULT = 0 ALIVE_TEST_TCP_ACK_SERVICE = 1 @@ -114,7 +114,7 @@ def prepare_scan_id_for_openvas(self): @property def target_options(self) -> Dict: - """ Return target options from Scan collection """ + """Return target options from Scan collection""" if self._target_options is not None: return self._target_options @@ -156,7 +156,7 @@ def _get_vts_in_groups( return vts_list def _get_vt_param_type(self, vt: Dict, vt_param_id: str) -> Optional[str]: - """ Return the type of the vt parameter from the vts dictionary. """ + """Return the type of the vt parameter from the vts dictionary.""" vt_params_list = vt.get("vt_params") if vt_params_list.get(vt_param_id): @@ -164,7 +164,7 @@ def _get_vt_param_type(self, vt: Dict, vt_param_id: str) -> Optional[str]: return None def _get_vt_param_name(self, vt: Dict, vt_param_id: str) -> Optional[str]: - """ Return the type of the vt parameter from the vts dictionary. """ + """Return the type of the vt parameter from the vts dictionary.""" vt_params_list = vt.get("vt_params") if vt_params_list.get(vt_param_id): @@ -210,7 +210,7 @@ def _process_vts( self, vts: Dict[str, Dict[str, str]], ) -> Tuple[List[str], Dict[str, str]]: - """ Add single VTs and their parameters. """ + """Add single VTs and their parameters.""" vts_list = [] vts_params = {} vtgroups = vts.pop('vt_groups') @@ -418,7 +418,7 @@ def build_alive_test_opt_as_prefs( return target_opt_prefs_list def prepare_alive_test_option_for_openvas(self): - """ Set alive test option. Overwrite the scan config settings.""" + """Set alive test option. Overwrite the scan config settings.""" settings = Openvas.get_settings() if settings and ( self.target_options.get('alive_test') @@ -499,7 +499,7 @@ def prepare_boreas_alive_test(self): self.kbdb.add_scan_preferences(self.scan_id, [pref]) def prepare_reverse_lookup_opt_for_openvas(self): - """ Set reverse lookup options in the kb""" + """Set reverse lookup options in the kb""" if self.target_options: items = [] _rev_lookup_only = int( diff --git a/ospd_openvas/vthelper.py b/ospd_openvas/vthelper.py index 4335a31d..092f67ec 100644 --- a/ospd_openvas/vthelper.py +++ b/ospd_openvas/vthelper.py @@ -157,7 +157,7 @@ def get_single_vt(self, vt_id: str, oids=None) -> Optional[Dict[str, any]]: def get_vt_iterator( self, vt_selection: List[str] = None, details: bool = True ) -> Iterator[Tuple[str, Dict]]: - """ Yield the vts from the Redis NVTicache. """ + """Yield the vts from the Redis NVTicache.""" oids = None if not vt_selection or details: @@ -174,7 +174,7 @@ def get_vt_iterator( yield (vt_id, vt) def calculate_vts_collection_hash(self) -> str: - """ Calculate the vts collection sha256 hash. """ + """Calculate the vts collection sha256 hash.""" m = sha256() # pylint: disable=invalid-name # for a reproducible hash calculation