From 2525260b3d12fa05c9e8d31a13ee4d14b6a4adef Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Thu, 11 May 2023 15:26:26 -0400 Subject: [PATCH] Only show passwords in entry reader if command ends in "--show" or "-s" Former-commit-id: 001d6e838c7b363897f3cdddefc5a75d581a1deb Former-commit-id: 4e291ece75777038e1ec9547be78d5acc1a58b12 --- lib/sshyp.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/sshyp.py b/lib/sshyp.py index 15eb761..2882774 100755 --- a/lib/sshyp.py +++ b/lib/sshyp.py @@ -50,7 +50,11 @@ def entry_reader(_decrypted_entry): if _num == 0 and _entry_lines[1] != '\n': print(f"\u001b[38;5;15;48;5;238musername:\u001b[0m\n{_entry_lines[1]}\n") elif _num == 1 and _entry_lines[0] != '\n': - print(f"\u001b[38;5;15;48;5;238mpassword:\u001b[0m\n{_entry_lines[0]}\n") + if pass_show: + print(f"\u001b[38;5;15;48;5;238mpassword:\u001b[0m\n\u001b[38;5;10m{_entry_lines[0]}\u001b[0m\n") + else: + print('\u001b[38;5;15;48;5;238mpassword:\u001b[0m\n\u001b[38;5;3mend command in "--show" or "-s" ' + 'to view\u001b[0m\n') elif _num == 2 and _entry_lines[2] != '\n': print(f"\u001b[38;5;15;48;5;238murl:\u001b[0m\n{_entry_lines[_num]}\n") elif _num >= 3 and _entry_lines[_num] != '\n' and _notes_flag != 1: @@ -821,17 +825,26 @@ def extension_runner(): if __name__ == "__main__": try: - ssh_error, success_flag, sync_flag, silent_sync = False, False, False, False + # set default states + ssh_error, success_flag, sync_flag, silent_sync, pass_show = False, False, False, False, False + # set to avoid PEP8 warnings arg_start, device_type = None, None + # retrieve typed argument arguments = argv[1:] arg_count = len(arguments) + # check if an entry name is correctly supplied if arg_count < 1 or (arg_count > 0 and arguments[0] != 'tweak'): if arg_count > 0 and arguments[0].startswith('/'): arg_start = 1 entry_name = arguments[0].strip('/') + # determine whether to show passwords in entry previews + if arg_count > 1 and arguments[arg_count-1] in ('--show', '-s'): + arguments.pop() + arg_count -= 1 + pass_show = True else: arg_start = 0