def Open(cls, fd, component, handlers, pathspec=None, progress_callback=None): # A Pathspec which starts with NTFS means we need to resolve the mount # point at runtime. if fd is None and component.pathtype == rdf_paths.PathSpec.PathType.NTFS: # We are the top level handler. This means we need to check the system # mounts to work out the exact mount point and device we need to # open. We then modify the pathspec so we get nested in the raw # pathspec. raw_pathspec, corrected_path = client_utils.GetRawDevice(component.path) # Insert the raw device before the component in the pathspec and correct # the path component.path = corrected_path pathspec.Insert(0, component) pathspec.Insert(0, raw_pathspec) # Allow incoming pathspec to be given in the local system path # conventions. for component in pathspec: if component.path: component.path = client_utils.LocalPathToCanonicalPath(component.path) # We have not actually opened anything in this iteration, but modified the # pathspec. Next time we should be able to open it properly. return fd else: return super(NTFSFile, cls).Open( fd=fd, component=component, handlers=handlers, pathspec=pathspec, progress_callback=progress_callback)
def Open(cls, fd, component, pathspec=None, progress_callback=None): # A Pathspec which starts with TSK means we need to resolve the mount point # at runtime. if fd is None and component.pathtype == rdf_paths.PathSpec.PathType.TSK: # We are the top level handler. This means we need to check the system # mounts to work out the exact mount point and device we need to # open. We then modify the pathspec so we get nested in the raw # pathspec. raw_pathspec, corrected_path = client_utils.GetRawDevice(component.path) # Insert the raw device before the component in the pathspec and correct # the path component.path = corrected_path pathspec.Insert(0, component) pathspec.Insert(0, raw_pathspec) # Allow incoming pathspec to be given in the local system path # conventions. for component in pathspec: if component.path: component.path = client_utils.LocalPathToCanonicalPath(component.path) # We have not actually opened anything in this iteration, but modified the # pathspec. Next time we should be able to open it properly. return fd # If an inode is specified, just use it directly. elif component.HasField("inode"): return TSKFile(fd, component, progress_callback=progress_callback) # Otherwise do the usual case folding. else: return vfs.VFSHandler.Open( fd, component, pathspec=pathspec, progress_callback=progress_callback)
def testGetRawDevice(self): if platform.system() == "Windows": path = "C:\\" else: path = "/" result, _ = client_utils.GetRawDevice(path) self.assertTrue(result.path)
def Open( cls, fd: Optional[vfs_base.VFSHandler], component: rdf_paths.PathSpec, handlers: Dict[Any, Type[vfs_base.VFSHandler]], pathspec: Optional[rdf_paths.PathSpec] = None, progress_callback: Optional[Callable[[], None]] = None ) -> Optional[vfs_base.VFSHandler]: # A Pathspec which starts with NTFS means we need to resolve the mount # point at runtime. if (fd is None and component.pathtype == rdf_paths.PathSpec.PathType.NTFS and pathspec is not None): # We are the top level handler. This means we need to check the system # mounts to work out the exact mount point and device we need to # open. We then modify the pathspec so we get nested in the raw # pathspec. raw_pathspec, corrected_path = client_utils.GetRawDevice( component.path) # Insert the raw device before the component in the pathspec and correct # the path component.path = corrected_path pathspec.Insert(0, component) pathspec.Insert(0, raw_pathspec) # Allow incoming pathspec to be given in the local system path # conventions. for component in pathspec: if component.path: component.path = client_utils.LocalPathToCanonicalPath( component.path) # We have not actually opened anything in this iteration, but modified the # pathspec. Next time we should be able to open it properly. return fd # If an inode is specified, just use it directly. # This is necessary so that component.path is ignored. elif component.HasField("inode"): return NTFSFile(fd, handlers, component, progress_callback=progress_callback) else: return super(NTFSFile, cls).Open(fd=fd, component=component, handlers=handlers, pathspec=pathspec, progress_callback=progress_callback)