Skip to content

Commit

Permalink
Refactor: pylint requires more complexity 80 lw.
Browse files Browse the repository at this point in the history
  • Loading branch information
nichtsfrei committed Dec 10, 2024
1 parent 1ed5016 commit a14dfdc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ospd_openvas/preferencehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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', '')
Expand Down

0 comments on commit a14dfdc

Please sign in to comment.