diff --git a/dfvfs/vfs/apfs_file_entry.py b/dfvfs/vfs/apfs_file_entry.py index 5f16fe35..49ebff4f 100644 --- a/dfvfs/vfs/apfs_file_entry.py +++ b/dfvfs/vfs/apfs_file_entry.py @@ -103,25 +103,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object. - """ - stat_object = super(APFSFileEntry, self)._GetStat() - - # Ownership and permissions stat information. - stat_object.mode = self._fsapfs_file_entry.file_mode & 0x0fff - stat_object.uid = self._fsapfs_file_entry.owner_identifier - stat_object.gid = self._fsapfs_file_entry.group_identifier - - # Other stat information. - stat_object.ino = self._fsapfs_file_entry.identifier - stat_object.fs_type = 'APFS' - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/cpio_file_entry.py b/dfvfs/vfs/cpio_file_entry.py index 39f3b2de..3caafcb3 100644 --- a/dfvfs/vfs/cpio_file_entry.py +++ b/dfvfs/vfs/cpio_file_entry.py @@ -96,24 +96,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object. - """ - stat_object = super(CPIOFileEntry, self)._GetStat() - - # Ownership and permissions stat information. - mode = getattr(self._cpio_archive_file_entry, 'mode', 0) - stat_object.mode = stat.S_IMODE(mode) - stat_object.uid = getattr( - self._cpio_archive_file_entry, 'user_identifier', None) - stat_object.gid = getattr( - self._cpio_archive_file_entry, 'group_identifier', None) - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/ext_file_entry.py b/dfvfs/vfs/ext_file_entry.py index b7b05cbc..47117315 100644 --- a/dfvfs/vfs/ext_file_entry.py +++ b/dfvfs/vfs/ext_file_entry.py @@ -120,33 +120,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object. - """ - stat_object = super(EXTFileEntry, self)._GetStat() - - # File data stat information. - stat_object.size = self._fsext_file_entry.size - - # Ownership and permissions stat information. - stat_object.mode = self._fsext_file_entry.file_mode & 0x0fff - stat_object.uid = self._fsext_file_entry.owner_identifier - stat_object.gid = self._fsext_file_entry.group_identifier - - # File entry type stat information. - stat_object.type = self.entry_type - - # Other stat information. - stat_object.ino = self._fsext_file_entry.inode_number - stat_object.fs_type = 'EXT' - - stat_object.is_allocated = True - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/file_entry.py b/dfvfs/vfs/file_entry.py index e7e1b9d4..c1ee5039 100644 --- a/dfvfs/vfs/file_entry.py +++ b/dfvfs/vfs/file_entry.py @@ -7,11 +7,9 @@ import abc -from dfvfs.lib import decorators from dfvfs.lib import definitions from dfvfs.resolver import resolver from dfvfs.vfs import data_stream -from dfvfs.vfs import vfs_stat class FileEntry(object): @@ -106,66 +104,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object. - """ - stat_object = vfs_stat.VFSStat() - - # Date and time stat information. - access_time = self.access_time - if access_time: - stat_time, stat_time_nano = access_time.CopyToStatTimeTuple() - if stat_time is not None: - stat_object.atime = stat_time - if stat_time_nano is not None: - stat_object.atime_nano = stat_time_nano - - change_time = self.change_time - if change_time: - stat_time, stat_time_nano = change_time.CopyToStatTimeTuple() - if stat_time is not None: - stat_object.ctime = stat_time - if stat_time_nano is not None: - stat_object.ctime_nano = stat_time_nano - - creation_time = self.creation_time - if creation_time: - stat_time, stat_time_nano = creation_time.CopyToStatTimeTuple() - if stat_time is not None: - stat_object.crtime = stat_time - if stat_time_nano is not None: - stat_object.crtime_nano = stat_time_nano - - modification_time = self.modification_time - if modification_time: - stat_time, stat_time_nano = modification_time.CopyToStatTimeTuple() - if stat_time is not None: - stat_object.mtime = stat_time - if stat_time_nano is not None: - stat_object.mtime_nano = stat_time_nano - - # File data stat information. - stat_object.size = self.size - - # Ownership and permissions stat information. - # TODO: consider adding stat_object.mode - # TODO: consider adding stat_object.uid - # TODO: consider adding stat_object.gid - - # File entry type stat information. - stat_object.type = self.entry_type - - # Other stat information. - # TODO: consider adding stat_object.ino - # TODO: consider adding stat_object.fs_type - - stat_object.is_allocated = self.IsAllocated() - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. @@ -379,17 +317,6 @@ def GetSubFileEntryByName(self, name, case_sensitive=True): return matching_sub_file_entry - @decorators.deprecated - def GetStat(self): - """Retrieves information about the file entry. - - This method is deprecated use GetStatAttribute instead. - - Returns: - VFSStat: a stat object or None if not available. - """ - return self._GetStat() - def GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/hfs_file_entry.py b/dfvfs/vfs/hfs_file_entry.py index 7489df39..c306e3e6 100644 --- a/dfvfs/vfs/hfs_file_entry.py +++ b/dfvfs/vfs/hfs_file_entry.py @@ -134,33 +134,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object. - """ - stat_object = super(HFSFileEntry, self)._GetStat() - - # File data stat information. - stat_object.size = self._fshfs_file_entry.size - - # Ownership and permissions stat information. - stat_object.mode = self._fshfs_file_entry.file_mode & 0x0fff - stat_object.uid = self._fshfs_file_entry.owner_identifier - stat_object.gid = self._fshfs_file_entry.group_identifier - - # File entry type stat information. - stat_object.type = self.entry_type - - # Other stat information. - stat_object.ino = self._fshfs_file_entry.identifier - stat_object.fs_type = 'HFS' - - stat_object.is_allocated = True - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/ntfs_file_entry.py b/dfvfs/vfs/ntfs_file_entry.py index d5970815..41909e7c 100644 --- a/dfvfs/vfs/ntfs_file_entry.py +++ b/dfvfs/vfs/ntfs_file_entry.py @@ -132,21 +132,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object. - """ - stat_object = super(NTFSFileEntry, self)._GetStat() - - # Other stat information. - file_reference = self._fsntfs_file_entry.file_reference - stat_object.ino = file_reference & self._FILE_REFERENCE_MFT_ENTRY_BITMASK - stat_object.fs_type = 'NTFS' - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/os_file_entry.py b/dfvfs/vfs/os_file_entry.py index f5d5d566..9c858113 100644 --- a/dfvfs/vfs/os_file_entry.py +++ b/dfvfs/vfs/os_file_entry.py @@ -142,25 +142,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object or None if not available. - """ - stat_object = super(OSFileEntry, self)._GetStat() - - if not self._is_windows_device and self._stat_info: - # Ownership and permissions stat information. - stat_object.mode = stat.S_IMODE(self._stat_info.st_mode) - stat_object.uid = self._stat_info.st_uid - stat_object.gid = self._stat_info.st_gid - - # Other stat information. - stat_object.ino = self._stat_info.st_ino - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/tar_file_entry.py b/dfvfs/vfs/tar_file_entry.py index 90036385..30a08a1a 100644 --- a/dfvfs/vfs/tar_file_entry.py +++ b/dfvfs/vfs/tar_file_entry.py @@ -79,21 +79,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves the stat object. - - Returns: - VFSStat: stat object. - """ - stat_object = super(TARFileEntry, self)._GetStat() - - # Ownership and permissions stat information. - stat_object.mode = getattr(self._tar_info, 'mode', None) - stat_object.uid = getattr(self._tar_info, 'uid', None) - stat_object.gid = getattr(self._tar_info, 'gid', None) - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/tsk_file_entry.py b/dfvfs/vfs/tsk_file_entry.py index 14d6aa4e..0538d242 100644 --- a/dfvfs/vfs/tsk_file_entry.py +++ b/dfvfs/vfs/tsk_file_entry.py @@ -153,18 +153,6 @@ def CopyToDateTimeString(self): year, month, day_of_month, hours, minutes, seconds, self.fraction_of_second) - def CopyToStatTimeTuple(self): - """Copies the SleuthKit timestamp to a stat timestamp tuple. - - Returns: - tuple[int, int]: a POSIX timestamp in seconds and the remainder in - 100 nano seconds or (None, None) on error. - """ - if self.fraction_of_second is None: - return self._timestamp, None - - return super(TSKTime, self).CopyToStatTimeTuple() - def GetDate(self): """Retrieves the date represented by the date and time values. @@ -444,42 +432,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves the stat object. - - Returns: - VFSStat: stat object. - """ - stat_object = super(TSKFileEntry, self)._GetStat() - - # Date and time stat information. - stat_time, stat_time_nano = self._TSKFileTimeCopyToStatTimeTuple( - self._tsk_file, 'bkup') - if stat_time is not None: - stat_object.bkup = stat_time - stat_object.bkup_nano = stat_time_nano - - stat_time, stat_time_nano = self._TSKFileTimeCopyToStatTimeTuple( - self._tsk_file, 'dtime') - if stat_time is not None: - stat_object.dtime = stat_time - stat_object.dtime_nano = stat_time_nano - - # Ownership and permissions stat information. - mode = getattr(self._tsk_file.info.meta, 'mode', None) - if mode is not None: - # We need to cast mode to an int since it is of type - # pytsk3.TSK_FS_META_MODE_ENUM. - stat_object.mode = int(mode) - - stat_object.uid = getattr(self._tsk_file.info.meta, 'uid', None) - stat_object.gid = getattr(self._tsk_file.info.meta, 'gid', None) - - # Other stat information. - stat_object.ino = getattr(self._tsk_file.info.meta, 'addr', None) - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. @@ -575,42 +527,6 @@ def _GetTimeValue(self, name): date_time.is_local_time = is_local_time return date_time - def _TSKFileTimeCopyToStatTimeTuple(self, tsk_file, time_value): - """Copies a SleuthKit file object time value to a stat timestamp tuple. - - Args: - tsk_file (pytsk3.File): TSK file. - time_value (str): name of the time value. - - Returns: - tuple[int, int]: number of seconds since 1970-01-01 00:00:00 and fraction - of second in 100 nano seconds intervals. The number of seconds is None - on error, or if the file system does not include the requested - timestamp. The fraction of second is None on error, or if the file - system does not support sub-second precision. - - Raises: - BackEndError: if the TSK File .info, .info.meta or info.fs_info - attribute is missing. - """ - if (not tsk_file or not tsk_file.info or not tsk_file.info.meta or - not tsk_file.info.fs_info): - raise errors.BackEndError( - 'Missing TSK File .info, .info.meta. or .info.fs_info') - - stat_time = getattr(tsk_file.info.meta, time_value, None) - stat_time_nano = None - if self._file_system_type in self._TSK_HAS_NANO_FS_TYPES: - time_value_nano = '{0:s}_nano'.format(time_value) - stat_time_nano = getattr(tsk_file.info.meta, time_value_nano, None) - - # Sleuthkit 4.2.0 switched from 100 nano seconds precision to - # 1 nano seconds precision. - if stat_time_nano is not None and pytsk3.TSK_VERSION_NUM >= 0x040200ff: - stat_time_nano /= 100 - - return stat_time, stat_time_nano - @property def access_time(self): """dfdatetime.DateTimeValues: access time or None if not available.""" diff --git a/dfvfs/vfs/vfs_stat.py b/dfvfs/vfs/vfs_stat.py deleted file mode 100644 index 5b5bd050..00000000 --- a/dfvfs/vfs/vfs_stat.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -"""The Virtual File System (VFS) stat object interface.""" - -# Note that if this file is name stat.py it will cause naming conflicts -# if used in combination with 'import stat'. - -# Note that the stat object is currently kept around for backwards -# compatibility. Having a file (entry) attribute object might be more -# flexible in dealing with e.g. NTFS attributes. - -from dfvfs.lib import definitions - - -class VFSStat(object): - """Class that implements the VFS stat object interface.""" - - TYPE_DEVICE = definitions.FILE_ENTRY_TYPE_DEVICE - TYPE_DIRECTORY = definitions.FILE_ENTRY_TYPE_DIRECTORY - TYPE_FILE = definitions.FILE_ENTRY_TYPE_FILE - TYPE_LINK = definitions.FILE_ENTRY_TYPE_LINK - TYPE_SOCKET = definitions.FILE_ENTRY_TYPE_SOCKET - TYPE_PIPE = definitions.FILE_ENTRY_TYPE_PIPE - - def __init__(self): - """Initializes the stat object.""" - super(VFSStat, self).__init__() - - # File data stat information. - self.size = None - - # Date and time stat information. - self.atime = None - self.mtime = None - - # Ownership and permissions stat information. - self.mode = None - self.uid = None - self.gid = None - - # File entry type stat information. - self.type = None - - # Other stat information. - # self.ino = None - # self.dev = None - # self.nlink = None - self.fs_type = None - self.is_allocated = True diff --git a/dfvfs/vfs/xfs_file_entry.py b/dfvfs/vfs/xfs_file_entry.py index 9574dc7d..7fbeb2a7 100644 --- a/dfvfs/vfs/xfs_file_entry.py +++ b/dfvfs/vfs/xfs_file_entry.py @@ -117,33 +117,6 @@ def _GetLink(self): return self._link - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object. - """ - stat_object = super(XFSFileEntry, self)._GetStat() - - # File data stat information. - stat_object.size = self._fsxfs_file_entry.size - - # Ownership and permissions stat information. - stat_object.mode = self._fsxfs_file_entry.file_mode & 0x0fff - stat_object.uid = self._fsxfs_file_entry.owner_identifier - stat_object.gid = self._fsxfs_file_entry.group_identifier - - # File entry type stat information. - stat_object.type = self.entry_type - - # Other stat information. - stat_object.ino = self._fsxfs_file_entry.inode_number - stat_object.fs_type = 'XFS' - - stat_object.is_allocated = True - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/dfvfs/vfs/zip_file_entry.py b/dfvfs/vfs/zip_file_entry.py index 57665c9e..cc888e10 100644 --- a/dfvfs/vfs/zip_file_entry.py +++ b/dfvfs/vfs/zip_file_entry.py @@ -73,23 +73,6 @@ def _GetDirectory(self): return zip_directory.ZIPDirectory(self._file_system, self.path_spec) - def _GetStat(self): - """Retrieves information about the file entry. - - Returns: - VFSStat: a stat object. - """ - stat_object = super(ZipFileEntry, self)._GetStat() - - if self._zip_info is not None: - # Ownership and permissions stat information. - if self._external_attributes != 0: - if self._creator_system == self._CREATOR_SYSTEM_UNIX: - st_mode = self._external_attributes >> 16 - stat_object.mode = st_mode & 0x0fff - - return stat_object - def _GetStatAttribute(self): """Retrieves a stat attribute. diff --git a/tests/vfs/apfs_container_file_entry.py b/tests/vfs/apfs_container_file_entry.py index 0dfb819b..7b7d1dad 100644 --- a/tests/vfs/apfs_container_file_entry.py +++ b/tests/vfs/apfs_container_file_entry.py @@ -177,19 +177,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_APFS_CONTAINER, parent=self._raw_path_spec, - volume_index=0) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - def testIsFunctions(self): """Test the Is? functions.""" path_spec = path_spec_factory.Factory.NewPathSpec( @@ -406,19 +393,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_APFS_CONTAINER, parent=self._gpt_path_spec, - volume_index=0) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - def testIsFunctions(self): """Test the Is? functions.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/apfs_file_entry.py b/tests/vfs/apfs_file_entry.py index f97ce763..aef1b543 100644 --- a/tests/vfs/apfs_file_entry.py +++ b/tests/vfs/apfs_file_entry.py @@ -168,38 +168,6 @@ def testGetAttributes(self): test_attribute_value_data = test_attribute.read() self.assertEqual(test_attribute_value_data, b'My extended attribute') - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_APFS, - identifier=self._IDENTIFIER_ANOTHER_FILE, - location='/a_directory/another_file', - parent=self._apfs_container_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 420) - self.assertEqual(stat_object.uid, 99) - self.assertEqual(stat_object.gid, 99) - - self.assertEqual(stat_object.atime, 1642144781) - self.assertEqual(stat_object.atime_nano, 2174301) - - self.assertEqual(stat_object.ctime, 1642144781) - self.assertEqual(stat_object.ctime_nano, 2206372) - - self.assertEqual(stat_object.crtime, 1642144781) - self.assertEqual(stat_object.crtime_nano, 2206372) - - self.assertEqual(stat_object.mtime, 1642144781) - self.assertEqual(stat_object.mtime_nano, 2174301) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( @@ -646,38 +614,6 @@ def testGetParentFileEntry(self): self.assertEqual(parent_file_entry.name, 'a_directory') - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_APFS, - identifier=self._IDENTIFIER_ANOTHER_FILE, - location='/a_directory/another_file', - parent=self._apfs_container_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 420) - self.assertEqual(stat_object.uid, 99) - self.assertEqual(stat_object.gid, 99) - - self.assertEqual(stat_object.atime, 1539321508) - self.assertEqual(stat_object.atime_nano, 9478457) - - self.assertEqual(stat_object.ctime, 1539321508) - self.assertEqual(stat_object.ctime_nano, 9495127) - - self.assertEqual(stat_object.crtime, 1539321508) - self.assertEqual(stat_object.crtime_nano, 9495127) - - self.assertEqual(stat_object.mtime, 1539321508) - self.assertEqual(stat_object.mtime_nano, 9478457) - def testIsFunctions(self): """Tests the Is? functions.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/bde_file_entry.py b/tests/vfs/bde_file_entry.py index b3151f84..4c438df0 100644 --- a/tests/vfs/bde_file_entry.py +++ b/tests/vfs/bde_file_entry.py @@ -120,7 +120,7 @@ def testGetDataStream(self): self.assertIsNone(data_stream) def testGetFileEntryByPathSpec(self): - """Test the get a file entry by path specification functionality.""" + """Tests the GetFileEntryByPathSpec function.""" file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) self.assertIsNotNone(file_entry) @@ -132,49 +132,40 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - # Currently the BDE volume needs to be unlocked before its size can - # be determined. - resolver.Resolver.key_chain.SetCredential( - self._bde_path_spec, 'password', self._BDE_PASSWORD) - - unlocked_file_system = bde_file_system.BDEFileSystem( - self._resolver_context, self._bde_path_spec) + def testIsAllocated(self): + """Test the IsAllocated function.""" + file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) - unlocked_file_system.Open() + self.assertIsNotNone(file_entry) + self.assertTrue(file_entry.IsAllocated()) - file_entry = unlocked_file_system.GetFileEntryByPathSpec( - self._bde_path_spec) + def testIsDevice(self): + """Test the IsDevice functions.""" + file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) self.assertIsNotNone(file_entry) + self.assertFalse(file_entry.IsDevice()) - stat_object = file_entry.GetStat() - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 67108864) - - self.assertEqual(stat_object.crtime, 1401712849) - self.assertEqual(stat_object.crtime_nano, 7281122) + def testIsDirectory(self): + """Test the IsDirectory functions.""" + file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) - resolver.Resolver.key_chain.SetCredential( - self._bde_path_spec, 'password', None) + self.assertIsNotNone(file_entry) + self.assertFalse(file_entry.IsDirectory()) - def testIsFunctions(self): - """Test the Is? functions.""" + def testIsFile(self): + """Test the IsFile functions.""" file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) + self.assertIsNotNone(file_entry) + self.assertTrue(file_entry.IsFile()) - self.assertTrue(file_entry.IsRoot()) - self.assertTrue(file_entry.IsVirtual()) - self.assertTrue(file_entry.IsAllocated()) + def testIsLink(self): + """Test the IsLink functions.""" + file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) - self.assertFalse(file_entry.IsDevice()) - self.assertFalse(file_entry.IsDirectory()) - self.assertTrue(file_entry.IsFile()) + self.assertIsNotNone(file_entry) self.assertFalse(file_entry.IsLink()) - self.assertFalse(file_entry.IsPipe()) - self.assertFalse(file_entry.IsSocket()) def testIsLocked(self): """Tests the IsLocked function.""" @@ -183,6 +174,34 @@ def testIsLocked(self): self.assertIsNotNone(file_entry) self.assertTrue(file_entry.IsLocked()) + def testIsPipe(self): + """Test the IsPipe functions.""" + file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) + + self.assertIsNotNone(file_entry) + self.assertFalse(file_entry.IsPipe()) + + def testIsRoot(self): + """Test the IsRoot functions.""" + file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) + + self.assertIsNotNone(file_entry) + self.assertTrue(file_entry.IsRoot()) + + def testIsSocket(self): + """Test the IsSocket functions.""" + file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) + + self.assertIsNotNone(file_entry) + self.assertFalse(file_entry.IsSocket()) + + def testIsVirtual(self): + """Test the IsVirtual functions.""" + file_entry = self._file_system.GetFileEntryByPathSpec(self._bde_path_spec) + + self.assertIsNotNone(file_entry) + self.assertTrue(file_entry.IsVirtual()) + if __name__ == '__main__': unittest.main() diff --git a/tests/vfs/compressed_stream_file_entry.py b/tests/vfs/compressed_stream_file_entry.py index d56e0991..d4557085 100644 --- a/tests/vfs/compressed_stream_file_entry.py +++ b/tests/vfs/compressed_stream_file_entry.py @@ -68,17 +68,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - file_entry = self._file_system.GetFileEntryByPathSpec( - self._compressed_stream_path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 1247) - def testIsFunctions(self): """Test the Is? functions.""" file_entry = self._file_system.GetFileEntryByPathSpec( diff --git a/tests/vfs/cpio_file_entry.py b/tests/vfs/cpio_file_entry.py index c23757b9..5fdabf18 100644 --- a/tests/vfs/cpio_file_entry.py +++ b/tests/vfs/cpio_file_entry.py @@ -48,27 +48,6 @@ def testIntialize(self): # TODO: test _GetDirectory # TODO: test _GetLink - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_CPIO, location='/syslog', - parent=self._os_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 1247) - - self.assertEqual(stat_object.mode, 436) - self.assertEqual(stat_object.uid, 1000) - self.assertEqual(stat_object.gid, 1000) - - self.assertEqual(stat_object.mtime, 1432702913) - self.assertFalse(hasattr(stat_object, 'mtime_nano')) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/cs_file_entry.py b/tests/vfs/cs_file_entry.py index 236beeef..9c622929 100644 --- a/tests/vfs/cs_file_entry.py +++ b/tests/vfs/cs_file_entry.py @@ -186,20 +186,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_CS, parent=self._gpt_path_spec, - volume_index=0) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 167772160) - def testIsFunctions(self): """Test the Is? functions.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/data_range_file_entry.py b/tests/vfs/data_range_file_entry.py index c8295ee3..51f6d66b 100644 --- a/tests/vfs/data_range_file_entry.py +++ b/tests/vfs/data_range_file_entry.py @@ -67,17 +67,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - file_entry = self._file_system.GetFileEntryByPathSpec( - self._data_range_path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 0x41) - def testIsFunctions(self): """Test the Is? functions.""" file_entry = self._file_system.GetFileEntryByPathSpec( diff --git a/tests/vfs/encoded_stream_file_entry.py b/tests/vfs/encoded_stream_file_entry.py index e094e8a3..3bcb0f7e 100644 --- a/tests/vfs/encoded_stream_file_entry.py +++ b/tests/vfs/encoded_stream_file_entry.py @@ -68,17 +68,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - file_entry = self._file_system.GetFileEntryByPathSpec( - self._encoded_stream_path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 1247) - def testIsFunctions(self): """Test the Is? functions.""" file_entry = self._file_system.GetFileEntryByPathSpec( diff --git a/tests/vfs/encrypted_stream_file_entry.py b/tests/vfs/encrypted_stream_file_entry.py index 8b01f5ad..0857db8e 100644 --- a/tests/vfs/encrypted_stream_file_entry.py +++ b/tests/vfs/encrypted_stream_file_entry.py @@ -73,17 +73,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - file_entry = self._file_system.GetFileEntryByPathSpec( - self._encrypted_stream_path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 1247) - def testIsFunctions(self): """Test the Is? functions.""" file_entry = self._file_system.GetFileEntryByPathSpec( diff --git a/tests/vfs/ext_file_entry.py b/tests/vfs/ext_file_entry.py index 96c1c2f6..1f9372eb 100644 --- a/tests/vfs/ext_file_entry.py +++ b/tests/vfs/ext_file_entry.py @@ -114,35 +114,6 @@ def testGetAttributes(self): test_attribute_value_data = test_attribute.read() self.assertEqual(test_attribute_value_data, b'My extended attribute') - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_EXT, inode=self._INODE_ANOTHER_FILE, - location='/a_directory/another_file', parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 436) - self.assertEqual(stat_object.uid, 1000) - self.assertEqual(stat_object.gid, 1000) - - self.assertEqual(stat_object.atime, 1626962852) - self.assertFalse(hasattr(stat_object, 'atime_nano')) - - self.assertEqual(stat_object.ctime, 1626962852) - self.assertFalse(hasattr(stat_object, 'ctime_nano')) - - self.assertFalse(hasattr(stat_object, 'crtime')) - - self.assertEqual(stat_object.mtime, 1626962852) - self.assertFalse(hasattr(stat_object, 'mtime_nano')) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( @@ -501,36 +472,6 @@ def testGetParentFileEntry(self): self.assertEqual(parent_file_entry.name, 'a_directory') - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_EXT, inode=self._INODE_ANOTHER_FILE, - location='/a_directory/another_file', parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 436) - self.assertEqual(stat_object.uid, 1000) - self.assertEqual(stat_object.gid, 1000) - - self.assertEqual(stat_object.atime, 1626962852) - self.assertEqual(stat_object.atime_nano, 8436108) - - self.assertEqual(stat_object.ctime, 1626962852) - self.assertEqual(stat_object.ctime_nano, 8436108) - - self.assertEqual(stat_object.crtime, 1626962852) - self.assertEqual(stat_object.crtime_nano, 8436108) - - self.assertEqual(stat_object.mtime, 1626962852) - self.assertEqual(stat_object.mtime_nano, 8436108) - def testIsFunctions(self): """Tests the Is? functions.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/fake_file_entry.py b/tests/vfs/fake_file_entry.py index 3285a486..69260dcf 100644 --- a/tests/vfs/fake_file_entry.py +++ b/tests/vfs/fake_file_entry.py @@ -152,25 +152,6 @@ def testGetParentFileEntry(self): self.assertEqual(parent_file_entry.name, 'testdir_fake') - def testGetStat(self): - """Tests the GetStat function.""" - test_file = '/test_data/testdir_fake/file1.txt' - path_spec = fake_path_spec.FakePathSpec(location=test_file) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 5) - - # The date and time values are in a seconds precision and - # cannot be predetermined. - self.assertNotEqual(stat_object.atime, 0) - self.assertNotEqual(stat_object.ctime, 0) - self.assertNotEqual(stat_object.mtime, 0) - def testIsFunctions(self): """Test the Is? functions.""" test_file = '/test_data/testdir_fake/file1.txt' diff --git a/tests/vfs/file_entry.py b/tests/vfs/file_entry.py index 29e2f4a1..6d802f5c 100644 --- a/tests/vfs/file_entry.py +++ b/tests/vfs/file_entry.py @@ -86,14 +86,6 @@ def testGetLink(self): symbolic_link = test_file_entry._GetLink() self.assertIsNotNone(symbolic_link) - def testGetStatProtected(self): - """Tests the _GetStat function.""" - test_file_entry = TestFileEntry( - self._resolver_context, self._file_system, self._path_spec) - - stat_object = test_file_entry._GetStat() - self.assertIsNotNone(stat_object) - def testAccessTime(self): """Tests the access_time property.""" test_file_entry = TestFileEntry( @@ -268,14 +260,6 @@ def testGetSubFileEntryByName(self): sub_file_entry = test_file_entry.GetSubFileEntryByName('bogus') self.assertIsNone(sub_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - test_file_entry = TestFileEntry( - self._resolver_context, self._file_system, self._path_spec) - - stat_object = test_file_entry.GetStat() - self.assertIsNotNone(stat_object) - def testHasDataStream(self): """Tests the HasDataStream function.""" test_file_entry = TestFileEntry( diff --git a/tests/vfs/fvde_file_entry.py b/tests/vfs/fvde_file_entry.py index 7aa47fe2..58a6fbf9 100644 --- a/tests/vfs/fvde_file_entry.py +++ b/tests/vfs/fvde_file_entry.py @@ -112,16 +112,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - file_entry = self._file_system.GetFileEntryByPathSpec(self._fvde_path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 167772160) - def testIsFunctions(self): """Test the Is? functions.""" file_entry = self._file_system.GetFileEntryByPathSpec(self._fvde_path_spec) diff --git a/tests/vfs/gpt_file_entry.py b/tests/vfs/gpt_file_entry.py index 5d3faae6..460c375e 100644 --- a/tests/vfs/gpt_file_entry.py +++ b/tests/vfs/gpt_file_entry.py @@ -112,24 +112,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_GPT, entry_index=0, - parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 65536) - - # TODO: implement in pyvsgpt - # self.assertEqual(stat_object.crtime, 0) - # self.assertEqual(stat_object.crtime_nano, 0) - def testIsFunctions(self): """Test the Is? functions.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/gzip_file_entry.py b/tests/vfs/gzip_file_entry.py index cf8a8a92..bd849093 100644 --- a/tests/vfs/gzip_file_entry.py +++ b/tests/vfs/gzip_file_entry.py @@ -73,20 +73,6 @@ def testGetParentFileEntry(self): self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - file_entry = self._file_system.GetFileEntryByPathSpec(self._gzip_path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 1247) - - self.assertEqual(stat_object.mtime, 1343493847) - self.assertFalse(hasattr(stat_object, 'mtime_nano')) - def testIsFunctions(self): """Test the Is? functions.""" file_entry = self._file_system.GetFileEntryByPathSpec(self._gzip_path_spec) diff --git a/tests/vfs/hfs_file_entry.py b/tests/vfs/hfs_file_entry.py index 013c5394..5af33768 100644 --- a/tests/vfs/hfs_file_entry.py +++ b/tests/vfs/hfs_file_entry.py @@ -96,38 +96,6 @@ def testGetDataStreams(self): data_streams = file_entry._GetDataStreams() self.assertEqual(len(data_streams), 2) - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_HFS, - identifier=self._IDENTIFIER_ANOTHER_FILE, - location='/a_directory/another_file', - parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 0o644) - self.assertEqual(stat_object.uid, 501) - self.assertEqual(stat_object.gid, 20) - - self.assertEqual(stat_object.atime, 1642144782) - self.assertFalse(hasattr(stat_object, 'atime_nano')) - - self.assertEqual(stat_object.ctime, 1642144782) - self.assertFalse(hasattr(stat_object, 'ctime_nano')) - - self.assertEqual(stat_object.crtime, 1642144782) - self.assertFalse(hasattr(stat_object, 'crtime_nano')) - - self.assertEqual(stat_object.mtime, 1642144782) - self.assertFalse(hasattr(stat_object, 'mtime_nano')) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/luksde_file_entry.py b/tests/vfs/luksde_file_entry.py index 5ac9c98a..e1543f0e 100644 --- a/tests/vfs/luksde_file_entry.py +++ b/tests/vfs/luksde_file_entry.py @@ -116,17 +116,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - file_entry = self._file_system.GetFileEntryByPathSpec( - self._luksde_path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 8388608) - def testIsFunctions(self): """Test the Is? functions.""" file_entry = self._file_system.GetFileEntryByPathSpec( diff --git a/tests/vfs/lvm_file_entry.py b/tests/vfs/lvm_file_entry.py index 3a8249d4..fc21c83d 100644 --- a/tests/vfs/lvm_file_entry.py +++ b/tests/vfs/lvm_file_entry.py @@ -188,24 +188,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_LVM, parent=self._raw_path_spec, - volume_index=0) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 4194304) - - # TODO: implement in pyvslvm - # self.assertEqual(stat_object.crtime, 0) - # self.assertEqual(stat_object.crtime_nano, 0) - def testIsFunctions(self): """Test the Is? functions.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/ntfs_file_entry.py b/tests/vfs/ntfs_file_entry.py index ef53af6d..af617b22 100644 --- a/tests/vfs/ntfs_file_entry.py +++ b/tests/vfs/ntfs_file_entry.py @@ -77,30 +77,6 @@ def testGetDataStreams(self): # TODO: add tests for _GetDirectory # TODO: add tests for _GetLink - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_NTFS, location='\\a_directory\\a_file', - mft_entry=self._MFT_ENTRY_A_FILE, parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.fs_type, 'NTFS') - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 53) - - self.assertEqual(stat_object.atime, 1567246979) - self.assertEqual(stat_object.atime_nano, 9567496) - self.assertEqual(stat_object.ctime, 1567246979) - self.assertEqual(stat_object.ctime_nano, 9581788) - self.assertEqual(stat_object.crtime, 1567246979) - self.assertEqual(stat_object.crtime_nano, 9567496) - self.assertEqual(stat_object.mtime, 1567246979) - self.assertEqual(stat_object.mtime_nano, 9581788) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/os_file_entry.py b/tests/vfs/os_file_entry.py index 07ea822d..6ce8f975 100644 --- a/tests/vfs/os_file_entry.py +++ b/tests/vfs/os_file_entry.py @@ -62,27 +62,6 @@ def testGetAttributes(self): # TODO: add tests for _GetDirectory # TODO: add tests for _GetLink - def testGetStat(self): - """Tests the _GetStat function.""" - test_path = self._GetTestFilePath(['testdir_os', 'file1.txt']) - self._SkipIfPathNotExists(test_path) - - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_OS, location=test_path) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 6) - - # The date and time values are in a seconds precision and - # cannot be predetermined. - self.assertNotEqual(stat_object.atime, 0) - self.assertNotEqual(stat_object.mtime, 0) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" test_path = self._GetTestFilePath(['testdir_os', 'file1.txt']) diff --git a/tests/vfs/sqlite_blob_file_entry.py b/tests/vfs/sqlite_blob_file_entry.py index 036cafe3..1e14d081 100644 --- a/tests/vfs/sqlite_blob_file_entry.py +++ b/tests/vfs/sqlite_blob_file_entry.py @@ -114,26 +114,6 @@ def testGetParentFileEntry(self): self.assertEqual(parent_file_entry.name, 'myblobs.blobs') - def testGetStat(self): - """Tests the GetStat function.""" - file_entry = self._file_system.GetFileEntryByPathSpec( - self._sqlite_blob_path_spec) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 110592) - - file_entry = self._file_system.GetFileEntryByPathSpec( - self._sqlite_blob_path_spec_2) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 11) - def testIsFunctions(self): """Test the Is? functions.""" file_entry = self._file_system.GetFileEntryByPathSpec( diff --git a/tests/vfs/tar_file_entry.py b/tests/vfs/tar_file_entry.py index 956a3351..260c7819 100644 --- a/tests/vfs/tar_file_entry.py +++ b/tests/vfs/tar_file_entry.py @@ -48,27 +48,6 @@ def testIntialize(self): # TODO: add tests for _GetDirectory # TODO: add tests for _GetLink - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_TAR, location='/syslog', - parent=self._os_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 1247) - - self.assertEqual(stat_object.mode, 256) - self.assertEqual(stat_object.uid, 151107) - self.assertEqual(stat_object.gid, 5000) - - self.assertEqual(stat_object.mtime, 1343166324) - self.assertFalse(hasattr(stat_object, 'mtime_nano')) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/tsk_file_entry.py b/tests/vfs/tsk_file_entry.py index 199e6ee2..33e9f214 100644 --- a/tests/vfs/tsk_file_entry.py +++ b/tests/vfs/tsk_file_entry.py @@ -34,23 +34,6 @@ def testCopyFromDateTimeString(self): self.assertEqual( tsk_time_object.fraction_of_second, expected_fraction_of_second) - def testCopyToStatTimeTuple(self): - """Tests the CopyToStatTimeTuple function.""" - if pytsk3.TSK_VERSION_NUM >= 0x040200ff: - fraction_of_second = 546875000 - else: - fraction_of_second = 5468750 - tsk_time_object = tsk_file_entry.TSKTime( - fraction_of_second=fraction_of_second, timestamp=1281643591) - - stat_time_tuple = tsk_time_object.CopyToStatTimeTuple() - self.assertEqual(stat_time_tuple, (1281643591, 5468750)) - - tsk_time_object = tsk_file_entry.TSKTime() - - stat_time_tuple = tsk_time_object.CopyToStatTimeTuple() - self.assertEqual(stat_time_tuple, (None, None)) - def testCopyToDateTimeString(self): """Tests the CopyToDateTimeString function.""" if pytsk3.TSK_VERSION_NUM >= 0x040200ff: @@ -173,37 +156,6 @@ def testGetDataStreams(self): # TODO: add tests for _GetDirectory # TODO: add tests for _GetLink - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_TSK, inode=self._INODE_ANOTHER_FILE, - location='/a_directory/another_file', parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 436) - self.assertEqual(stat_object.uid, 1000) - self.assertEqual(stat_object.gid, 1000) - - self.assertEqual(stat_object.atime, 1626962852) - self.assertFalse(hasattr(stat_object, 'atime_nano')) - - self.assertEqual(stat_object.ctime, 1626962852) - self.assertFalse(hasattr(stat_object, 'ctime_nano')) - - # EXT2 has no crtime timestamp. - self.assertFalse(hasattr(stat_object, 'crtime')) - self.assertFalse(hasattr(stat_object, 'crtime_nano')) - - self.assertEqual(stat_object.mtime, 1626962852) - self.assertFalse(hasattr(stat_object, 'mtime_nano')) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( @@ -225,7 +177,6 @@ def testGetStatAttribute(self): # TODO: add tests for _GetSubFileEntries # TODO: add tests for _GetTimeValue - # TODO: add tests for _TSKFileTimeCopyToStatTimeTuple def testAccessTime(self): """Test the access_time property.""" @@ -593,37 +544,6 @@ def testGetDataStreams(self): # TODO: add tests for _GetDirectory # TODO: add tests for _GetLink - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_TSK, inode=self._INODE_ANOTHER_FILE, - location='/a_directory/another_file', parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 511) - self.assertEqual(stat_object.uid, 0) - self.assertEqual(stat_object.gid, 0) - - self.assertEqual(stat_object.atime, 1618704000) - self.assertFalse(hasattr(stat_object, 'atime_nano')) - - # FAT has no ctime timestamp. - self.assertFalse(hasattr(stat_object, 'ctime')) - self.assertFalse(hasattr(stat_object, 'ctime_nano')) - - self.assertEqual(stat_object.crtime, 1618758550) - self.assertFalse(hasattr(stat_object, 'crtime_nano')) - - self.assertEqual(stat_object.mtime, 1618758550) - self.assertFalse(hasattr(stat_object, 'mtime_nano')) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( @@ -645,7 +565,6 @@ def testGetStatAttribute(self): # TODO: add tests for _GetSubFileEntries # TODO: add tests for _GetTimeValue - # TODO: add tests for _TSKFileTimeCopyToStatTimeTuple def testAccessTime(self): """Test the access_time property.""" @@ -998,36 +917,6 @@ def testGetDataStreams(self): # TODO: add tests for _GetDirectory # TODO: add tests for _GetLink - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_TSK, inode=self._INODE_ANOTHER_FILE, - location='/a_directory/another_file', parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 420) - self.assertEqual(stat_object.uid, 501) - self.assertEqual(stat_object.gid, 20) - - self.assertEqual(stat_object.atime, 1642144782) - self.assertEqual(stat_object.atime_nano, 0) - - self.assertEqual(stat_object.ctime, 1642144782) - self.assertEqual(stat_object.ctime_nano, 0) - - self.assertEqual(stat_object.crtime, 1642144782) - self.assertEqual(stat_object.crtime_nano, 0) - - self.assertEqual(stat_object.mtime, 1642144782) - self.assertEqual(stat_object.mtime_nano, 0) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( @@ -1049,7 +938,6 @@ def testGetStatAttribute(self): # TODO: add tests for _GetSubFileEntries # TODO: add tests for _GetTimeValue - # TODO: add tests for _TSKFileTimeCopyToStatTimeTuple def testAccessTime(self): """Test the access_time property.""" @@ -1462,33 +1350,6 @@ def testGetDataStreams(self): # TODO: add tests for _GetDirectory # TODO: add tests for _GetLink - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_TSK, inode=self._MFT_ENTRY_ANOTHER_FILE, - location='/a_directory/another_file', parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 511) - self.assertEqual(stat_object.uid, 48) - self.assertEqual(stat_object.gid, 0) - - self.assertEqual(stat_object.atime, 1567246979) - self.assertEqual(stat_object.atime_nano, 9602053) - self.assertEqual(stat_object.ctime, 1567246979) - self.assertEqual(stat_object.ctime_nano, 9611209) - self.assertEqual(stat_object.crtime, 1567246979) - self.assertEqual(stat_object.crtime_nano, 9602053) - self.assertEqual(stat_object.mtime, 1567246979) - self.assertEqual(stat_object.mtime_nano, 9611209) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( @@ -1510,7 +1371,6 @@ def testGetStatAttribute(self): # TODO: add tests for _GetSubFileEntries # TODO: add tests for _GetTimeValue - # TODO: add tests for _TSKFileTimeCopyToStatTimeTuple def testAccessTime(self): """Test the access_time property.""" diff --git a/tests/vfs/tsk_partition_file_entry.py b/tests/vfs/tsk_partition_file_entry.py index 41371975..5d8b0eed 100644 --- a/tests/vfs/tsk_partition_file_entry.py +++ b/tests/vfs/tsk_partition_file_entry.py @@ -90,20 +90,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_TSK_PARTITION, part_index=0, - parent=self._os_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 512) - # TODO: add tests for GetTSKVsPart def testIsFunctions(self): @@ -290,20 +276,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_TSK_PARTITION, part_index=1, - parent=self._os_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 512) - # TODO: add tests for GetTSKVsPart def testIsFunctions(self): diff --git a/tests/vfs/vshadow_file_entry.py b/tests/vfs/vshadow_file_entry.py index 2f40c779..217c5844 100644 --- a/tests/vfs/vshadow_file_entry.py +++ b/tests/vfs/vshadow_file_entry.py @@ -121,23 +121,6 @@ def testGetParentFileEntry(self): parent_file_entry = file_entry.GetParentFileEntry() self.assertIsNone(parent_file_entry) - def testGetStat(self): - """Tests the GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_VSHADOW, parent=self._raw_path_spec, - store_index=1) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry.GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 82771968) - - self.assertEqual(stat_object.crtime, 1619890888) - self.assertEqual(stat_object.crtime_nano, 2249863) - # TODO: add tests for GetVShadowStore # TODO: add tests for HasExternalData diff --git a/tests/vfs/xfs_file_entry.py b/tests/vfs/xfs_file_entry.py index 698da8a3..de4c9783 100644 --- a/tests/vfs/xfs_file_entry.py +++ b/tests/vfs/xfs_file_entry.py @@ -124,36 +124,6 @@ def testGetAttributes(self): test_attribute_value_data = test_attribute.read() self.assertEqual(test_attribute_value_data, b'My extended attribute') - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_XFS, inode=self._INODE_ANOTHER_FILE, - location='/a_directory/another_file', parent=self._raw_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 22) - - self.assertEqual(stat_object.mode, 0o664) - self.assertEqual(stat_object.uid, 1000) - self.assertEqual(stat_object.gid, 1000) - - self.assertEqual(stat_object.atime, 1626962854) - self.assertEqual(stat_object.atime_nano, 8136161) - - self.assertEqual(stat_object.ctime, 1626962854) - self.assertEqual(stat_object.ctime_nano, 8146161) - - self.assertEqual(stat_object.crtime, 1626962854) - self.assertEqual(stat_object.crtime_nano, 8136161) - - self.assertEqual(stat_object.mtime, 1626962854) - self.assertEqual(stat_object.mtime_nano, 8146161) - def testGetStatAttribute(self): """Tests the _GetStatAttribute function.""" path_spec = path_spec_factory.Factory.NewPathSpec( diff --git a/tests/vfs/zip_file_entry.py b/tests/vfs/zip_file_entry.py index 5817d99f..9dd99afe 100644 --- a/tests/vfs/zip_file_entry.py +++ b/tests/vfs/zip_file_entry.py @@ -46,42 +46,6 @@ def testIntialize(self): self.assertIsNotNone(file_entry) # TODO: add tests for _GetDirectory function. - - def testGetStat(self): - """Tests the _GetStat function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_ZIP, location='/syslog', - parent=self._os_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_object = file_entry._GetStat() - - self.assertIsNotNone(stat_object) - self.assertEqual(stat_object.type, stat_object.TYPE_FILE) - self.assertEqual(stat_object.size, 1247) - - self.assertEqual(stat_object.mode, 256) - - self.assertEqual(stat_object.mtime, 1343141124) - # TODO: re-enable when dfdatetime updates are committed - # self.assertEqual(stat_object.mtime_nano, None) - - def testGetStatAttribute(self): - """Tests the _GetStatAttribute function.""" - path_spec = path_spec_factory.Factory.NewPathSpec( - definitions.TYPE_INDICATOR_ZIP, location='/syslog', - parent=self._os_path_spec) - file_entry = self._file_system.GetFileEntryByPathSpec(path_spec) - self.assertIsNotNone(file_entry) - - stat_attribute = file_entry._GetStatAttribute() - - self.assertIsNotNone(stat_attribute) - self.assertEqual(stat_attribute.mode, 0o100400) - self.assertEqual(stat_attribute.size, 1247) - self.assertEqual(stat_attribute.type, stat_attribute.TYPE_FILE) - # TODO: add tests for _GetSubFileEntries def testAccessTime(self):