Skip to content

Commit

Permalink
Merge pull request #410 from greenbone/dependabot/pip/black-21.4b0
Browse files Browse the repository at this point in the history
Bump black from 20.8b1 to 21.4b0
  • Loading branch information
jjnicola authored Apr 26, 2021
2 parents e7ab7ab + d3bb1e9 commit f5e388d
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 63 deletions.
14 changes: 7 additions & 7 deletions ospd_openvas/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)


Expand Down
10 changes: 5 additions & 5 deletions ospd_openvas/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -470,15 +470,15 @@ 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):
return '<{} index={}>'.format(self.__class__.__name__, self.index)


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.
Expand Down Expand Up @@ -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))

Expand All @@ -563,7 +563,7 @@ def get_scan_status(self) -> List:


class MainDB(BaseDB):
""" Main Database """
"""Main Database"""

DEFAULT_INDEX = 0

Expand Down
14 changes: 7 additions & 7 deletions ospd_openvas/preferencehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@


class AliveTest(IntEnum):
""" Alive Tests. """
"""Alive Tests."""

ALIVE_TEST_SCAN_CONFIG_DEFAULT = 0
ALIVE_TEST_TCP_ACK_SERVICE = 1
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -156,15 +156,15 @@ 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):
return vt_params_list[vt_param_id]["type"]
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):
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions ospd_openvas/vthelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
80 changes: 40 additions & 40 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ pylint = "^2.8.1"
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"}
pontos = "^21.4.0"

black = {version = "21.4b0", python = "^3.7"}

[tool.poetry.scripts]
ospd-openvas = "ospd_openvas.daemon:main"
Expand Down

0 comments on commit f5e388d

Please sign in to comment.