idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
19,400
def GetVolumeByIndex ( self , volume_index ) : if not self . _is_parsed : self . _Parse ( ) self . _is_parsed = True if volume_index < 0 or volume_index >= len ( self . _volume_identifiers ) : return None volume_identifier = self . _volume_identifiers [ volume_index ] return self . _volumes [ volume_identifier ]
Retrieves a specific volume based on the index .
19,401
def _GetUncompressedStreamSize ( self ) : self . _file_object . seek ( 0 , os . SEEK_SET ) self . _decompressor = self . _GetDecompressor ( ) self . _uncompressed_data = b'' compressed_data_offset = 0 compressed_data_size = self . _file_object . get_size ( ) uncompressed_stream_size = 0 while compressed_data_offset < c...
Retrieves the uncompressed stream size .
19,402
def GetVShadowStoreByPathSpec ( self , path_spec ) : store_index = vshadow . VShadowPathSpecGetStoreIndex ( path_spec ) if store_index is None : return None return self . _vshadow_volume . get_store ( store_index )
Retrieves a VSS store for a path specification .
19,403
def deprecated ( function ) : def IssueDeprecationWarning ( * args , ** kwargs ) : warnings . simplefilter ( 'default' , DeprecationWarning ) warnings . warn ( 'Call to deprecated function: {0:s}.' . format ( function . __name__ ) , category = DeprecationWarning , stacklevel = 2 ) return function ( * args , ** kwargs )...
Decorator to mark functions or methods as deprecated .
19,404
def _CheckFileEntryType ( self , file_entry ) : if not self . _file_entry_types : return None return ( self . _CheckIsDevice ( file_entry ) or self . _CheckIsDirectory ( file_entry ) or self . _CheckIsFile ( file_entry ) or self . _CheckIsLink ( file_entry ) or self . _CheckIsPipe ( file_entry ) or self . _CheckIsSocke...
Checks the file entry type find specifications .
19,405
def _CheckIsDevice ( self , file_entry ) : if definitions . FILE_ENTRY_TYPE_DEVICE not in self . _file_entry_types : return False return file_entry . IsDevice ( )
Checks the is_device find specification .
19,406
def _CheckIsDirectory ( self , file_entry ) : if definitions . FILE_ENTRY_TYPE_DIRECTORY not in self . _file_entry_types : return False return file_entry . IsDirectory ( )
Checks the is_directory find specification .
19,407
def _CheckIsFile ( self , file_entry ) : if definitions . FILE_ENTRY_TYPE_FILE not in self . _file_entry_types : return False return file_entry . IsFile ( )
Checks the is_file find specification .
19,408
def _CheckIsLink ( self , file_entry ) : if definitions . FILE_ENTRY_TYPE_LINK not in self . _file_entry_types : return False return file_entry . IsLink ( )
Checks the is_link find specification .
19,409
def _CheckIsPipe ( self , file_entry ) : if definitions . FILE_ENTRY_TYPE_PIPE not in self . _file_entry_types : return False return file_entry . IsPipe ( )
Checks the is_pipe find specification .
19,410
def _CheckIsSocket ( self , file_entry ) : if definitions . FILE_ENTRY_TYPE_SOCKET not in self . _file_entry_types : return False return file_entry . IsSocket ( )
Checks the is_socket find specification .
19,411
def _CheckLocation ( self , file_entry , search_depth ) : if self . _location_segments is None : return False if search_depth < 0 or search_depth > self . _number_of_location_segments : return False if search_depth == 0 : segment_name = '' else : segment_name = self . _location_segments [ search_depth - 1 ] if self . _...
Checks the location find specification .
19,412
def Matches ( self , file_entry , search_depth ) : if self . _location_segments is None : location_match = None else : location_match = self . _CheckLocation ( file_entry , search_depth ) if not location_match : return False , location_match if search_depth != self . _number_of_location_segments : return False , locati...
Determines if the file entry matches the find specification .
19,413
def PrepareMatches ( self , file_system ) : if self . _location is not None : self . _location_segments = self . _SplitPath ( self . _location , file_system . PATH_SEPARATOR ) elif self . _location_regex is not None : path_separator = file_system . PATH_SEPARATOR if path_separator == '\\' : path_separator = '\\\\' self...
Prepare find specification for matching .
19,414
def _FindInFileEntry ( self , file_entry , find_specs , search_depth ) : sub_find_specs = [ ] for find_spec in find_specs : match , location_match = find_spec . Matches ( file_entry , search_depth ) if match : yield file_entry . path_spec if location_match != False and not find_spec . AtMaximumDepth ( search_depth ) : ...
Searches for matching file entries within the file entry .
19,415
def Find ( self , find_specs = None ) : if not find_specs : find_specs . append ( FindSpec ( ) ) for find_spec in find_specs : find_spec . PrepareMatches ( self . _file_system ) if path_spec_factory . Factory . IsSystemLevelTypeIndicator ( self . _file_system . type_indicator ) : file_entry = self . _file_system . GetF...
Searches for matching file entries within the file system .
19,416
def GetRelativePath ( self , path_spec ) : location = getattr ( path_spec , 'location' , None ) if location is None : raise errors . PathSpecError ( 'Path specification missing location.' ) if path_spec_factory . Factory . IsSystemLevelTypeIndicator ( self . _file_system . type_indicator ) : if not location . startswit...
Returns the relative path based on a resolved path specification .
19,417
def _PromptUserForEncryptedVolumeCredential ( self , scan_context , locked_scan_node , output_writer ) : credentials = credentials_manager . CredentialsManager . GetCredentials ( locked_scan_node . path_spec ) if locked_scan_node . type_indicator == ( definitions . TYPE_INDICATOR_APFS_CONTAINER ) : line = 'Found an APF...
Prompts the user to provide a credential for an encrypted volume .
19,418
def Analyze ( self , source_path , output_writer ) : if not os . path . exists ( source_path ) : raise RuntimeError ( 'No such source: {0:s}.' . format ( source_path ) ) scan_context = source_scanner . SourceScannerContext ( ) scan_path_spec = None scan_step = 0 scan_context . OpenSourcePath ( source_path ) while True ...
Analyzes the source .
19,419
def WriteScanContext ( self , scan_context , scan_step = None ) : if scan_step is not None : print ( 'Scan step: {0:d}' . format ( scan_step ) ) print ( 'Source type\t\t: {0:s}' . format ( scan_context . source_type ) ) print ( '' ) scan_node = scan_context . GetRootScanNode ( ) self . WriteScanNode ( scan_context , sc...
Writes the source scanner context to stdout .
19,420
def WriteScanNode ( self , scan_context , scan_node , indentation = '' ) : if not scan_node : return values = [ ] part_index = getattr ( scan_node . path_spec , 'part_index' , None ) if part_index is not None : values . append ( '{0:d}' . format ( part_index ) ) store_index = getattr ( scan_node . path_spec , 'store_in...
Writes the source scanner node to stdout .
19,421
def _CalculateHashDataStream ( self , file_entry , data_stream_name ) : hash_context = hashlib . sha256 ( ) try : file_object = file_entry . GetFileObject ( data_stream_name = data_stream_name ) except IOError as exception : logging . warning ( ( 'Unable to open path specification:\n{0:s}' 'with error: {1!s}' ) . forma...
Calculates a message digest hash of the data of the file entry .
19,422
def _CalculateHashesFileEntry ( self , file_system , file_entry , parent_full_path , output_writer ) : full_path = file_system . JoinPath ( [ parent_full_path , file_entry . name ] ) for data_stream in file_entry . data_streams : hash_value = self . _CalculateHashDataStream ( file_entry , data_stream . name ) display_p...
Recursive calculates hashes starting with the file entry .
19,423
def _GetDisplayPath ( self , path_spec , full_path , data_stream_name ) : display_path = '' if path_spec . HasParent ( ) : parent_path_spec = path_spec . parent if parent_path_spec and parent_path_spec . type_indicator == ( dfvfs_definitions . TYPE_INDICATOR_TSK_PARTITION ) : display_path = '' . join ( [ display_path ,...
Retrieves a path to display .
19,424
def CalculateHashes ( self , base_path_specs , output_writer ) : for base_path_spec in base_path_specs : file_system = resolver . Resolver . OpenFileSystem ( base_path_spec ) file_entry = resolver . Resolver . OpenFileEntry ( base_path_spec ) if file_entry is None : logging . warning ( 'Unable to open base path specifi...
Recursive calculates hashes starting with the base path specification .
19,425
def _EncodeString ( self , string ) : try : encoded_string = string . encode ( self . _encoding , errors = self . _errors ) except UnicodeEncodeError : if self . _errors == 'strict' : logging . error ( 'Unable to properly write output due to encoding error. ' 'Switching to error tolerant encoding which can result in ' ...
Encodes the string .
19,426
def WriteFileHash ( self , path , hash_value ) : string = '{0:s}\t{1:s}\n' . format ( hash_value , path ) encoded_string = self . _EncodeString ( string ) self . _file_object . write ( encoded_string )
Writes the file path and hash to file .
19,427
def WriteFileHash ( self , path , hash_value ) : string = '{0:s}\t{1:s}' . format ( hash_value , path ) encoded_string = self . _EncodeString ( string ) print ( encoded_string )
Writes the file path and hash to stdout .
19,428
def GetLinkedFileEntry ( self ) : link = self . _GetLink ( ) if not link : return None path_spec = os_path_spec . OSPathSpec ( location = link ) return OSFileEntry ( self . _resolver_context , self . _file_system , path_spec )
Retrieves the linked file entry for example for a symbolic link .
19,429
def GetAPFSVolumeByPathSpec ( self , path_spec ) : volume_index = apfs_helper . APFSContainerPathSpecGetVolumeIndex ( path_spec ) if volume_index is None : return None return self . _fsapfs_container . get_volume ( volume_index )
Retrieves an APFS volume for a path specification .
19,430
def Glob2Regex ( glob_pattern ) : if not glob_pattern : raise ValueError ( 'Missing glob pattern.' ) regex_pattern = [ ] glob_pattern_index = 0 glob_pattern_length = len ( glob_pattern ) while glob_pattern_index < glob_pattern_length : character = glob_pattern [ glob_pattern_index ] glob_pattern_index += 1 if character...
Converts a glob pattern to a regular expression .
19,431
def CacheObject ( self , identifier , vfs_object ) : if identifier in self . _values : raise KeyError ( 'Object already cached for identifier: {0:s}' . format ( identifier ) ) if len ( self . _values ) == self . _maximum_number_of_cached_values : raise errors . CacheFullError ( 'Maximum number of cached values reached....
Caches a VFS object .
19,432
def GetCacheValueByObject ( self , vfs_object ) : for identifier , cache_value in iter ( self . _values . items ( ) ) : if not cache_value : raise RuntimeError ( 'Missing cache value.' ) if cache_value . vfs_object == vfs_object : return identifier , cache_value return None , None
Retrieves the cache value for the cached object .
19,433
def GetObject ( self , identifier ) : cache_value = self . _values . get ( identifier , None ) if not cache_value : return None return cache_value . vfs_object
Retrieves a cached object based on the identifier .
19,434
def GrabObject ( self , identifier ) : if identifier not in self . _values : raise KeyError ( 'Missing cached object for identifier: {0:s}' . format ( identifier ) ) cache_value = self . _values [ identifier ] if not cache_value : raise RuntimeError ( 'Missing cache value for identifier: {0:s}' . format ( identifier ) ...
Grabs a cached object based on the identifier .
19,435
def ReleaseObject ( self , identifier ) : if identifier not in self . _values : raise KeyError ( 'Missing cached object for identifier: {0:s}' . format ( identifier ) ) cache_value = self . _values [ identifier ] if not cache_value : raise RuntimeError ( 'Missing cache value for identifier: {0:s}' . format ( identifier...
Releases a cached object based on the identifier .
19,436
def RemoveObject ( self , identifier ) : if identifier not in self . _values : raise KeyError ( 'Missing cached object for identifier: {0:s}' . format ( identifier ) ) del self . _values [ identifier ]
Removes a cached object based on the identifier .
19,437
def GetSecurityDescriptor ( self ) : fwnt_security_descriptor = pyfwnt . security_descriptor ( ) fwnt_security_descriptor . copy_from_byte_stream ( self . _fsntfs_file_entry . security_descriptor_data ) return fwnt_security_descriptor
Retrieves the security descriptor .
19,438
def _ReadFileEntries ( self , file_object ) : self . _file_entries = { } file_offset = 0 while file_offset < self . _file_size or self . _file_size == 0 : file_entry = self . _ReadFileEntry ( file_object , file_offset ) file_offset += file_entry . size if file_entry . path == 'TRAILER!!!' : break if file_entry . path i...
Reads the file entries from the cpio archive .
19,439
def GetFileEntries ( self , path_prefix = '' ) : if self . _file_entries : for path , file_entry in iter ( self . _file_entries . items ( ) ) : if path . startswith ( path_prefix ) : yield file_entry
Retrieves the file entries .
19,440
def Open ( self , file_object ) : file_object . seek ( 0 , os . SEEK_SET ) signature_data = file_object . read ( 6 ) self . file_format = None if len ( signature_data ) > 2 : if signature_data [ : 2 ] == self . _CPIO_SIGNATURE_BINARY_BIG_ENDIAN : self . file_format = 'bin-big-endian' elif signature_data [ : 2 ] == self...
Opens the CPIO archive file .
19,441
def ReadDataAtOffset ( self , file_offset , size ) : self . _file_object . seek ( file_offset , os . SEEK_SET ) return self . _file_object . read ( size )
Reads a byte string from the file - like object at a specific offset .
19,442
def GetNTFSFileEntryByPathSpec ( self , path_spec ) : location = getattr ( path_spec , 'location' , None ) mft_attribute = getattr ( path_spec , 'mft_attribute' , None ) mft_entry = getattr ( path_spec , 'mft_entry' , None ) if mft_attribute is not None and mft_entry is not None : fsntfs_file_entry = self . _fsntfs_vol...
Retrieves the NTFS file entry for a path specification .
19,443
def _RawGlobPathSpecWithAlphabeticalSchema ( file_system , parent_path_spec , segment_format , location , segment_length , upper_case = False ) : segment_number = 0 segment_files = [ ] while True : segment_index = segment_number segment_letters = [ ] while len ( segment_letters ) < segment_length : segment_index , rema...
Globs for path specifications according to an alphabetical naming schema .
19,444
def _RawGlobPathSpecWithNumericSchema ( file_system , parent_path_spec , segment_format , location , segment_number ) : segment_files = [ ] while True : segment_location = segment_format . format ( location , segment_number ) kwargs = path_spec_factory . Factory . GetProperties ( parent_path_spec ) kwargs [ 'location' ...
Globs for path specifications according to a numeric naming schema .
19,445
def GetSubNodeByLocation ( self , location ) : for sub_node in self . sub_nodes : sub_node_location = getattr ( sub_node . path_spec , 'location' , None ) if location == sub_node_location : return sub_node return None
Retrieves a sub scan node based on the location .
19,446
def GetUnscannedSubNode ( self ) : if not self . sub_nodes and not self . scanned : return self for sub_node in self . sub_nodes : result = sub_node . GetUnscannedSubNode ( ) if result : return result return None
Retrieves the first unscanned sub node .
19,447
def AddScanNode ( self , path_spec , parent_scan_node ) : scan_node = self . _scan_nodes . get ( path_spec , None ) if scan_node : raise KeyError ( 'Scan node already exists.' ) scan_node = SourceScanNode ( path_spec ) if parent_scan_node : if parent_scan_node . path_spec not in self . _scan_nodes : raise RuntimeError ...
Adds a scan node for a certain path specification .
19,448
def GetUnscannedScanNode ( self ) : root_scan_node = self . _scan_nodes . get ( self . _root_path_spec , None ) if not root_scan_node or not root_scan_node . scanned : return root_scan_node return root_scan_node . GetUnscannedSubNode ( )
Retrieves the first unscanned scan node .
19,449
def LockScanNode ( self , path_spec ) : scan_node = self . _scan_nodes . get ( path_spec , None ) if not scan_node : raise KeyError ( 'Scan node does not exist.' ) self . _locked_scan_nodes [ path_spec ] = scan_node
Marks a scan node as locked .
19,450
def OpenSourcePath ( self , source_path ) : source_path_spec = path_spec_factory . Factory . NewPathSpec ( definitions . TYPE_INDICATOR_OS , location = source_path ) self . AddScanNode ( source_path_spec , None )
Opens the source path .
19,451
def RemoveScanNode ( self , path_spec ) : scan_node = self . _scan_nodes . get ( path_spec , None ) if not scan_node : return None if scan_node . sub_nodes : raise RuntimeError ( 'Scan node has sub nodes.' ) parent_scan_node = scan_node . parent_node if parent_scan_node : parent_scan_node . sub_nodes . remove ( scan_no...
Removes a scan node of a certain path specification .
19,452
def UnlockScanNode ( self , path_spec ) : if not self . HasScanNode ( path_spec ) : raise KeyError ( 'Scan node does not exist.' ) if path_spec not in self . _locked_scan_nodes : raise KeyError ( 'Scan node is not locked.' ) del self . _locked_scan_nodes [ path_spec ] self . _scan_nodes [ path_spec ] . scanned = False
Marks a scan node as unlocked .
19,453
def _ScanNode ( self , scan_context , scan_node , auto_recurse = True ) : if not scan_context : raise ValueError ( 'Invalid scan context.' ) if not scan_node : raise ValueError ( 'Invalid scan node.' ) scan_path_spec = scan_node . path_spec system_level_file_entry = None if scan_node . IsSystemLevel ( ) : system_level_...
Scans a node for supported formats .
19,454
def _ScanEncryptedVolumeNode ( self , scan_context , scan_node ) : if scan_node . type_indicator == definitions . TYPE_INDICATOR_APFS_CONTAINER : container_file_entry = resolver . Resolver . OpenFileEntry ( scan_node . path_spec , resolver_context = self . _resolver_context ) fsapfs_volume = container_file_entry . GetA...
Scans an encrypted volume node for supported formats .
19,455
def _ScanVolumeSystemRootNode ( self , scan_context , scan_node , auto_recurse = True ) : if scan_node . type_indicator == definitions . TYPE_INDICATOR_VSHADOW : path_spec = self . ScanForFileSystem ( scan_node . path_spec . parent ) if path_spec : scan_context . AddScanNode ( path_spec , scan_node . parent_node ) file...
Scans a volume system root node for supported formats .
19,456
def GetVolumeIdentifiers ( self , volume_system ) : volume_identifiers = [ ] for volume in volume_system . volumes : volume_identifier = getattr ( volume , 'identifier' , None ) if volume_identifier : volume_identifiers . append ( volume_identifier ) return sorted ( volume_identifiers )
Retrieves the volume identifiers .
19,457
def Scan ( self , scan_context , auto_recurse = True , scan_path_spec = None ) : if not scan_context : raise ValueError ( 'Invalid scan context.' ) scan_context . updated = False if scan_path_spec : scan_node = scan_context . GetScanNode ( scan_path_spec ) else : scan_node = scan_context . GetUnscannedScanNode ( ) if s...
Scans for supported formats .
19,458
def ScanForFileSystem ( self , source_path_spec ) : if source_path_spec . type_indicator == ( definitions . TYPE_INDICATOR_APFS_CONTAINER ) : return path_spec_factory . Factory . NewPathSpec ( definitions . TYPE_INDICATOR_APFS , location = '/' , parent = source_path_spec ) try : type_indicators = analyzer . Analyzer . ...
Scans the path specification for a supported file system format .
19,459
def ScanForStorageMediaImage ( self , source_path_spec ) : try : type_indicators = analyzer . Analyzer . GetStorageMediaImageTypeIndicators ( source_path_spec , resolver_context = self . _resolver_context ) except RuntimeError as exception : raise errors . BackEndError ( ( 'Unable to process source path specification w...
Scans the path specification for a supported storage media image format .
19,460
def ScanForVolumeSystem ( self , source_path_spec ) : if source_path_spec . type_indicator == definitions . TYPE_INDICATOR_VSHADOW : return None if source_path_spec . IsVolumeSystemRoot ( ) : return source_path_spec if source_path_spec . type_indicator == ( definitions . TYPE_INDICATOR_APFS_CONTAINER ) : return None tr...
Scans the path specification for a supported volume system format .
19,461
def _WriteRow ( self , output_writer , values , in_bold = False ) : row_strings = [ ] for value_index , value_string in enumerate ( values ) : padding_size = self . _column_sizes [ value_index ] - len ( value_string ) padding_string = ' ' * padding_size row_strings . extend ( [ value_string , padding_string ] ) row_str...
Writes a row of values aligned with the width to the output writer .
19,462
def Write ( self , output_writer ) : for column_index , column_size in enumerate ( self . _column_sizes ) : column_size , _ = divmod ( column_size , self . _NUMBER_OF_SPACES_IN_TAB ) column_size = ( column_size + 1 ) * self . _NUMBER_OF_SPACES_IN_TAB self . _column_sizes [ column_index ] = column_size if self . _column...
Writes the table to output writer .
19,463
def GetVSSStoreIdentifiers ( self , volume_system , volume_identifiers ) : print_header = True while True : if print_header : self . _PrintVSSStoreIdentifiersOverview ( volume_system , volume_identifiers ) print_header = False self . _output_writer . Write ( '\n' ) lines = self . _textwrapper . wrap ( self . _USER_PROM...
Retrieves VSS store identifiers .
19,464
def UnlockEncryptedVolume ( self , source_scanner_object , scan_context , locked_scan_node , credentials ) : if locked_scan_node . type_indicator == ( definitions . TYPE_INDICATOR_APFS_CONTAINER ) : header = 'Found an APFS encrypted volume.' elif locked_scan_node . type_indicator == definitions . TYPE_INDICATOR_BDE : h...
Unlocks an encrypted volume .
19,465
def GetTARInfo ( self ) : if not self . _tar_info : location = getattr ( self . path_spec , 'location' , None ) if location is None : raise errors . PathSpecError ( 'Path specification missing location.' ) if not location . startswith ( self . _file_system . LOCATION_ROOT ) : raise errors . PathSpecError ( 'Invalid loc...
Retrieves the TAR info .
19,466
def GetDecoder ( cls , encoding_method ) : encoding_method = encoding_method . lower ( ) decoder = cls . _decoders . get ( encoding_method , None ) if not decoder : return None return decoder ( )
Retrieves the decoder object for a specific encoding method .
19,467
def RegisterDecoder ( cls , decoder ) : encoding_method = decoder . ENCODING_METHOD . lower ( ) if encoding_method in cls . _decoders : raise KeyError ( 'Decoder for encoding method: {0:s} already set.' . format ( decoder . ENCODING_METHOD ) ) cls . _decoders [ encoding_method ] = decoder
Registers a decoder for a specific encoding method .
19,468
def _GetDirectory ( self ) : if self . entry_type != definitions . FILE_ENTRY_TYPE_DIRECTORY : return None return LVMDirectory ( self . _file_system , self . path_spec )
Retrieves the directory .
19,469
def GetTSKVsPartByPathSpec ( tsk_volume , path_spec ) : location = getattr ( path_spec , 'location' , None ) part_index = getattr ( path_spec , 'part_index' , None ) start_offset = getattr ( path_spec , 'start_offset' , None ) partition_index = None if part_index is None : if location is not None : if location . starts...
Retrieves the TSK volume system part object from the TSK volume object .
19,470
def TSKVolumeGetBytesPerSector ( tsk_volume ) : if hasattr ( tsk_volume , 'info' ) and tsk_volume . info is not None : block_size = getattr ( tsk_volume . info , 'block_size' , 512 ) else : block_size = 512 return block_size
Retrieves the number of bytes per sector from a TSK volume object .
19,471
def _OpenParentFile ( self , file_system , path_spec , vhdi_file ) : location = getattr ( path_spec , 'location' , None ) if not location : raise errors . PathSpecError ( 'Unsupported path specification without location.' ) location_path_segments = file_system . SplitPath ( location ) parent_filename = vhdi_file . pare...
Opens the parent file .
19,472
def DeregisterDecrypter ( cls , decrypter ) : encryption_method = decrypter . ENCRYPTION_METHOD . lower ( ) if encryption_method not in cls . _decrypters : raise KeyError ( 'Decrypter for encryption method: {0:s} not set.' . format ( decrypter . ENCRYPTION_METHOD ) ) del cls . _decrypters [ encryption_method ]
Deregisters a decrypter for a specific encryption method .
19,473
def GetDecrypter ( cls , encryption_method , ** kwargs ) : encryption_method = encryption_method . lower ( ) decrypter = cls . _decrypters . get ( encryption_method , None ) if not decrypter : return None return decrypter ( ** kwargs )
Retrieves the decrypter object for a specific encryption method .
19,474
def GetTARInfoByPathSpec ( self , path_spec ) : location = getattr ( path_spec , 'location' , None ) if location is None : raise errors . PathSpecError ( 'Path specification missing location.' ) if not location . startswith ( self . LOCATION_ROOT ) : raise errors . PathSpecError ( 'Invalid location in path specificatio...
Retrieves the TAR info for a path specification .
19,475
def GetCPIOArchiveFileEntryByPathSpec ( self , path_spec ) : location = getattr ( path_spec , 'location' , None ) if location is None : raise errors . PathSpecError ( 'Path specification missing location.' ) if not location . startswith ( self . LOCATION_ROOT ) : raise errors . PathSpecError ( 'Invalid location in path...
Retrieves the CPIO archive file entry for a path specification .
19,476
def _PathStripPrefix ( self , path ) : if path . startswith ( '\\\\.\\' ) or path . startswith ( '\\\\?\\' ) : if len ( path ) < 7 or path [ 5 ] != ':' or path [ 6 ] != self . _PATH_SEPARATOR : return None path = path [ 7 : ] elif path . startswith ( '\\\\' ) : return None elif len ( path ) >= 3 and path [ 1 ] == ':' :...
Strips the prefix from a path .
19,477
def SetEnvironmentVariable ( self , name , value ) : if isinstance ( value , py2to3 . STRING_TYPES ) : value = self . _PathStripPrefix ( value ) if value is not None : self . _environment_variables [ name . upper ( ) ] = value
Sets an environment variable in the Windows path helper .
19,478
def APFSUnlockVolume ( fsapfs_volume , path_spec , key_chain ) : is_locked = fsapfs_volume . is_locked ( ) if is_locked : password = key_chain . GetCredential ( path_spec , 'password' ) if password : fsapfs_volume . set_password ( password ) recovery_password = key_chain . GetCredential ( path_spec , 'recovery_password...
Unlocks an APFS volume using the path specification .
19,479
def GetNumberOfRows ( self ) : if not self . _database_object : raise IOError ( 'Not opened.' ) if self . _number_of_rows is None : self . _number_of_rows = self . _database_object . GetNumberOfRows ( self . _table_name ) return self . _number_of_rows
Retrieves the number of rows of the table .
19,480
def GetZipInfoByPathSpec ( self , path_spec ) : location = getattr ( path_spec , 'location' , None ) if location is None : raise errors . PathSpecError ( 'Path specification missing location.' ) if not location . startswith ( self . LOCATION_ROOT ) : raise errors . PathSpecError ( 'Invalid location in path specificatio...
Retrieves the ZIP info for a path specification .
19,481
def GetAPFSFileEntryByPathSpec ( self , path_spec ) : location = getattr ( path_spec , 'location' , None ) identifier = getattr ( path_spec , 'identifier' , None ) if identifier is not None : fsapfs_file_entry = self . _fsapfs_volume . get_file_entry_by_identifier ( identifier ) elif location is not None : fsapfs_file_...
Retrieves the APFS file entry for a path specification .
19,482
def DeregisterPathSpec ( cls , path_spec_type ) : type_indicator = path_spec_type . TYPE_INDICATOR if type_indicator not in cls . _path_spec_types : raise KeyError ( 'Path specification type: {0:s} not set.' . format ( type_indicator ) ) del cls . _path_spec_types [ type_indicator ] if type_indicator in cls . _system_l...
Deregisters a path specification .
19,483
def GetProperties ( cls , path_spec ) : properties = { } for property_name in cls . PROPERTY_NAMES : if hasattr ( path_spec , property_name ) : properties [ property_name ] = getattr ( path_spec , property_name ) return properties
Retrieves a dictionary containing the path specification properties .
19,484
def NewPathSpec ( cls , type_indicator , ** kwargs ) : if type_indicator not in cls . _path_spec_types : raise KeyError ( 'Path specification type: {0:s} not set.' . format ( type_indicator ) ) if 'parent' in kwargs and kwargs [ 'parent' ] is None : del kwargs [ 'parent' ] path_spec_type = cls . _path_spec_types [ type...
Creates a new path specification for the specific type indicator .
19,485
def RegisterPathSpec ( cls , path_spec_type ) : type_indicator = path_spec_type . TYPE_INDICATOR if type_indicator in cls . _path_spec_types : raise KeyError ( 'Path specification type: {0:s} already set.' . format ( type_indicator ) ) cls . _path_spec_types [ type_indicator ] = path_spec_type if getattr ( path_spec_ty...
Registers a path specification type .
19,486
def _ReadString ( self , file_object , file_offset , data_type_map , description ) : element_data_size = ( data_type_map . _element_data_type_definition . GetByteSize ( ) ) elements_terminator = ( data_type_map . _data_type_definition . elements_terminator ) byte_stream = [ ] element_data = file_object . read ( element...
Reads a string .
19,487
def _ReadStructure ( self , file_object , file_offset , data_size , data_type_map , description ) : data = self . _ReadData ( file_object , file_offset , data_size , description ) return self . _ReadStructureFromByteStream ( data , file_offset , data_type_map , description )
Reads a structure .
19,488
def read ( self , offset , size ) : self . _file_object . seek ( offset , os . SEEK_SET ) return self . _file_object . read ( size )
Reads a byte string from the image object at the specified offset .
19,489
def CopyFromDateTimeString ( self , time_string ) : date_time_values = self . _CopyDateTimeFromString ( time_string ) year = date_time_values . get ( 'year' , 0 ) month = date_time_values . get ( 'month' , 0 ) day_of_month = date_time_values . get ( 'day_of_month' , 0 ) hours = date_time_values . get ( 'hours' , 0 ) mi...
Copies a SleuthKit timestamp from a date and time string .
19,490
def CopyToDateTimeString ( self ) : if self . _timestamp is None : return None number_of_days , hours , minutes , seconds = self . _GetTimeValues ( self . _timestamp ) year , month , day_of_month = self . _GetDateValues ( number_of_days , 1970 , 1 , 1 ) if self . fraction_of_second is None : return '{0:04d}-{1:02d}-{2:...
Copies the date time value to a date and time string .
19,491
def CopyToStatTimeTuple ( self ) : if self . fraction_of_second is None : return self . _timestamp , None return super ( TSKTime , self ) . CopyToStatTimeTuple ( )
Copies the SleuthKit timestamp to a stat timestamp tuple .
19,492
def IsDefault ( self ) : if not self . _tsk_attribute or not self . _file_system : return True if self . _file_system . IsHFS ( ) : attribute_type = getattr ( self . _tsk_attribute . info , 'type' , None ) return attribute_type in ( pytsk3 . TSK_FS_ATTR_TYPE_HFS_DEFAULT , pytsk3 . TSK_FS_ATTR_TYPE_HFS_DATA ) if self . ...
Determines if the data stream is the default data stream .
19,493
def _GetTimeValue ( self , name ) : timestamp = getattr ( self . _tsk_file . info . meta , name , None ) if self . _file_system_type in self . _TSK_HAS_NANO_FS_TYPES : name_fragment = '{0:s}_nano' . format ( name ) fraction_of_second = getattr ( self . _tsk_file . info . meta , name_fragment , None ) else : fraction_of...
Retrieves a date and time value .
19,494
def _TSKFileTimeCopyToStatTimeTuple ( self , tsk_file , time_value ) : 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_va...
Copies a SleuthKit file object time value to a stat timestamp tuple .
19,495
def FVDEVolumeOpen ( fvde_volume , path_spec , file_object , key_chain ) : encrypted_root_plist = key_chain . GetCredential ( path_spec , 'encrypted_root_plist' ) if encrypted_root_plist : fvde_volume . read_encrypted_root_plist ( encrypted_root_plist ) password = key_chain . GetCredential ( path_spec , 'password' ) if...
Opens the FVDE volume using the path specification .
19,496
def VShadowPathSpecGetStoreIndex ( path_spec ) : store_index = getattr ( path_spec , 'store_index' , None ) if store_index is None : location = getattr ( path_spec , 'location' , None ) if location is None or not location . startswith ( '/vss' ) : return None store_index = None try : store_index = int ( location [ 4 : ...
Retrieves the store index from the path specification .
19,497
def _GetMemberForOffset ( self , offset ) : if offset < 0 or offset >= self . uncompressed_data_size : raise ValueError ( 'Offset {0:d} is larger than file size {1:d}.' . format ( offset , self . uncompressed_data_size ) ) for end_offset , member in iter ( self . _members_by_end_offset . items ( ) ) : if offset < end_o...
Finds the member whose data includes the provided offset .
19,498
def read ( self , size = None ) : data = b'' while ( ( size and len ( data ) < size ) and self . _current_offset < self . uncompressed_data_size ) : member = self . _GetMemberForOffset ( self . _current_offset ) member_offset = self . _current_offset - member . uncompressed_data_offset data_read = member . ReadAtOffset...
Reads a byte string from the gzip file at the current offset .
19,499
def _GetStat ( self ) : stat_object = vfs_stat . VFSStat ( ) stat_object . size = self . path_spec . range_size stat_object . type = stat_object . TYPE_FILE return stat_object
Retrieves a stat object .