Skip to content

Commit

Permalink
Fix nul byte not trimmed from win32 creds
Browse files Browse the repository at this point in the history
Signed-off-by: Timothy Johnson <[email protected]>
  • Loading branch information
t1m0thyj committed Nov 7, 2023
1 parent f2f361a commit 8817566
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/core/zowe/core_for_zowe_sdk/credential_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def _get_credential(service_name: str, account_name: str) -> Optional[str]:
index += 1
temp_value = keyring.get_password(service_name, f"{account_name}-{index}")

if encoded_credential is not None and encoded_credential.endswith("\0"):
encoded_credential = encoded_credential[:-1]

return encoded_credential

@staticmethod
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_zowe_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ def test_retrieve_credential(self, get_pass_func):
# Scenario 2: Retrieve password in parts
expected_password2 = "part1part2"
retrieve_credential2 = credential_manager._get_credential(constants["ZoweServiceName"], constants["ZoweAccountName"])
retrieve_credential2 = retrieve_credential2[:-1]
self.assertEqual(retrieve_credential2, expected_password2)
get_pass_func.assert_any_call(constants["ZoweServiceName"], constants["ZoweAccountName"])
get_pass_func.assert_any_call(constants["ZoweServiceName"], f"{constants['ZoweAccountName']}-1")
Expand Down

0 comments on commit 8817566

Please sign in to comment.