From 8fe9b3236617af8fb61f40eacf6117773f2290be Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 11 May 2022 12:12:24 -0400 Subject: [PATCH] UT: Expect WindowsPath in assert_windows_permissions() --- monkey/tests/monkey_island/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/monkey/tests/monkey_island/utils.py b/monkey/tests/monkey_island/utils.py index 8ab767774..f72adfef7 100644 --- a/monkey/tests/monkey_island/utils.py +++ b/monkey/tests/monkey_island/utils.py @@ -1,3 +1,5 @@ +from pathlib import WindowsPath + from monkey_island.cc.server_utils.file_utils import is_windows_os if is_windows_os(): @@ -12,16 +14,16 @@ else: import stat -def _get_acl_and_sid_from_path(path: str): +def _get_acl_and_sid_from_path(path: WindowsPath): sid, _, _ = win32security.LookupAccountName("", win32api.GetUserName()) security_descriptor = win32security.GetNamedSecurityInfo( - path, win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION + str(path), win32security.SE_FILE_OBJECT, win32security.DACL_SECURITY_INFORMATION ) acl = security_descriptor.GetSecurityDescriptorDacl() return acl, sid -def assert_windows_permissions(path: str): +def assert_windows_permissions(path: WindowsPath): acl, user_sid = _get_acl_and_sid_from_path(path) assert acl.GetAceCount() == 1