From a14dfdcdf1eff69228100564a02bd485065de595 Mon Sep 17 00:00:00 2001 From: Philipp Eder Date: Tue, 10 Dec 2024 09:19:31 +0000 Subject: [PATCH] Refactor: pylint requires more complexity 80 lw. --- ospd_openvas/preferencehandler.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ospd_openvas/preferencehandler.py b/ospd_openvas/preferencehandler.py index fabe607c..8c70a32e 100644 --- a/ospd_openvas/preferencehandler.py +++ b/ospd_openvas/preferencehandler.py @@ -577,6 +577,11 @@ def prepare_scan_params_for_openvas(self, ospd_params: Dict[str, Dict]): if prefs_val: self.kbdb.add_scan_preferences(self.scan_id, prefs_val) + def disable_message(self, disabled: str) -> str: + """Return a string with the message for exclusive services.""" + disabled = f"Disabled {disabled}" + return disabled + ": KRB5 and SMB credentials are mutually exclusive." + def build_credentials_as_prefs(self, credentials: Dict) -> List[str]: """Parse the credential dictionary. Arguments: @@ -586,6 +591,7 @@ def build_credentials_as_prefs(self, credentials: Dict) -> List[str]: A list with the credentials in string format to be added to the redis KB. """ + cred_prefs_list = [] krb5_set = False smb_set = False @@ -668,9 +674,7 @@ def build_credentials_as_prefs(self, credentials: Dict) -> List[str]: # Check servic smb elif service == 'smb': if krb5_set: - self.errors.append( - "Disabled SMB: Kerberos and SMB credentials are mutually exclusive." - ) + self.errors.append(self.disable_message("SMB")) continue smb_set = True cred_prefs_list.append( @@ -681,9 +685,7 @@ def build_credentials_as_prefs(self, credentials: Dict) -> List[str]: ) elif service == 'krb5': if smb_set: - self.errors.append( - "Disabled KRB5: Kerberos and SMB credentials are mutually exclusive." - ) + self.errors.append(self.disable_message("KRB5")) continue krb5_set = True realm = cred_params.get('realm', '')