Adding error handling for unexpected powershell output, see issue #93

main
Alexander Neff 2023-11-11 17:13:41 -05:00
parent 079c224f17
commit 75190da24a
1 changed files with 12 additions and 6 deletions

View File

@ -149,12 +149,18 @@ class NXCModule:
context.log.fail(output_stripped[0]) context.log.fail(output_stripped[0])
return return
for account in output_stripped: # When powershell returns something else than the usernames and passwords account.split() will throw a ValueError.
user, password = account.split(" ", 1) # This is likely an error thrown by powershell, so we print the error and the output for debugging purposes.
password = password.replace("WHITESPACE_ERROR", " ") try:
context.log.highlight(user + ":" + f"{password}") for account in output_stripped:
if " " in password: user, password = account.split(" ", 1)
context.log.fail(f'Password contains whitespaces! The password for user "{user}" is: "{password}"') password = password.replace("WHITESPACE_ERROR", " ")
context.log.highlight(user + ":" + f"{password}")
if " " in password:
context.log.fail(f'Password contains whitespaces! The password for user "{user}" is: "{password}"')
except ValueError:
context.log.fail(f"Powershell returned unexpected output: {output_stripped}")
context.log.fail("Please report this issue on GitHub!")
def on_admin_login(self, context, connection): def on_admin_login(self, context, connection):
self.checkVeeamInstalled(context, connection) self.checkVeeamInstalled(context, connection)