def test_get_system_acl(self): """Tests the get_system_acl function.""" security_descriptor = pyfwnt.security_descriptor() security_descriptor.copy_from_byte_stream(self._TEST_DATA) access_control_list = security_descriptor.get_system_acl() self.assertIsNotNone(access_control_list)
def _FormatSecurityDescriptor(self, security_descriptor_data): """Formats security descriptor. Args: security_descriptor_data (bytes): security descriptor data. Returns: str: formatted security descriptor. """ fwnt_descriptor = pyfwnt.security_descriptor() fwnt_descriptor.copy_from_byte_stream(security_descriptor_data) lines = [] if fwnt_descriptor.owner: identifier_string = fwnt_descriptor.owner.get_string() value_string = '\tOwner: {0:s}'.format(identifier_string) lines.append(value_string) if fwnt_descriptor.group: identifier_string = fwnt_descriptor.group.get_string() value_string = '\tGroup: {0:s}'.format(identifier_string) lines.append(value_string) # TODO: format SACL # TODO: format DACL lines.append('') return '\n'.join(lines)
def test_get_group(self): """Tests the get_group function.""" security_descriptor = pyfwnt.security_descriptor() security_descriptor.copy_from_byte_stream(self._TEST_DATA) security_identifier = security_descriptor.get_group() self.assertIsNotNone(security_identifier) string = security_identifier.get_string() self.assertEqual(string, 'S-1-5-32-544')
def test_copy_from_byte_stream(self): """Tests the copy_from_byte_stream function.""" security_descriptor = pyfwnt.security_descriptor() security_descriptor.copy_from_byte_stream(self._TEST_DATA) with self.assertRaises(TypeError): security_descriptor.copy_from_byte_stream(None) with self.assertRaises(IOError): security_descriptor.copy_from_byte_stream(self._TEST_DATA[:16])
def test_get_owner(self): """Tests the get_owner function.""" security_descriptor = pyfwnt.security_descriptor() security_descriptor.copy_from_byte_stream(self._TEST_DATA) security_identifier = security_descriptor.get_owner() self.assertIsNotNone(security_identifier) string = security_identifier.get_string() self.assertEqual(string, 'S-1-5-21-1757981266-484763869-1060284298-1003')
def GetSecurityDescriptor(self): """Retrieves the security descriptor. Returns: pyfwnt.security_descriptor: security descriptor. """ fwnt_security_descriptor = pyfwnt.security_descriptor() fwnt_security_descriptor.copy_from_byte_stream( self._fsntfs_file_entry.security_descriptor_data) return fwnt_security_descriptor
def GetSecurityDescriptor(self): """Retrieves the security descriptor. Returns: pyfwnt.security_descriptor: security descriptor. Raises: BackEndError: if the pyfsntfs file entry is missing. """ fsntfs_file_entry = self.GetNTFSFileEntry() if not fsntfs_file_entry: raise errors.BackEndError(u'Missing pyfsntfs file entry.') fwnt_security_descriptor = pyfwnt.security_descriptor() fwnt_security_descriptor.copy_from_byte_stream( fsntfs_file_entry.security_descriptor_data) return fwnt_security_descriptor
def security_descriptor(self): """pyfwnt.security_descriptor: security descriptor.""" fwnt_security_descriptor = pyfwnt.security_descriptor() fwnt_security_descriptor.copy_from_byte_stream( self._fsntfs_attribute.data) return fwnt_security_descriptor
def security_descriptor(self): """pyfwnt.security_descriptor: security descriptor.""" fwnt_security_descriptor = pyfwnt.security_descriptor() fwnt_security_descriptor.copy_from_byte_stream(self._fsntfs_attribute.data) return fwnt_security_descriptor