def _CreateTaskStorageMergeReader(self, path): """Creates a task storage merge reader. Args: path (str): path to the task storage file that should be merged. Returns: SQLiteStorageMergeReader: storage merge reader. """ return merge_reader.SQLiteStorageMergeReader(self, path)
def _CreateTaskStorageMergeReader(self, task): """Creates a task storage merge reader. Args: task (Task): task. Returns: StorageMergeReader: storage merge reader. """ path = self._GetMergeTaskStorageFilePath(task) return merge_reader.SQLiteStorageMergeReader(self, path)
def _CreateTaskStorageMergeReader(self, task): """Creates a task storage merge reader. Args: task (Task): task. Returns: StorageMergeReader: storage merge reader. """ if task.storage_format == definitions.STORAGE_FORMAT_REDIS: return redis_merge_reader.RedisMergeReader(self, task) path = self._GetMergeTaskStorageFilePath(task) return merge_reader.SQLiteStorageMergeReader(self, path)
def testReadStorageMetadata(self): """Tests the _ReadStorageMetadata function.""" session = sessions.Session() with shared_test_lib.TempDirectory() as temp_directory: task_storage_path = os.path.join(temp_directory, 'task.sqlite') self._CreateTaskStorageFile(session, task_storage_path) session_storage_path = os.path.join(temp_directory, 'plaso.sqlite') storage_writer = writer.SQLiteStorageFileWriter( session, session_storage_path) test_reader = merge_reader.SQLiteStorageMergeReader( storage_writer, task_storage_path) test_reader._Open() test_reader._ReadStorageMetadata() test_reader._Close()
def _CreateTaskStorageMergeReader(self, task): """Creates a task storage merge reader. Args: task (Task): task. Returns: StorageMergeReader: storage merge reader. """ if task.storage_format == definitions.STORAGE_FORMAT_REDIS: task_merge_reader = redis_merge_reader.RedisMergeReader(self, task) else: path = self._GetMergeTaskStorageFilePath(task) task_merge_reader = merge_reader.SQLiteStorageMergeReader( self, path) task_merge_reader.SetStorageProfiler(self._storage_profiler) return task_merge_reader
def testMergeAttributeContainers(self): """Tests the MergeAttributeContainers function.""" session = sessions.Session() with shared_test_lib.TempDirectory() as temp_directory: task_storage_path = os.path.join(temp_directory, 'task.sqlite') self._CreateTaskStorageFile(session, task_storage_path) session_storage_path = os.path.join(temp_directory, 'plaso.sqlite') storage_writer = writer.SQLiteStorageFileWriter( session, session_storage_path) test_reader = merge_reader.SQLiteStorageMergeReader( storage_writer, task_storage_path) storage_writer.Open() result = test_reader.MergeAttributeContainers() self.assertTrue(result) storage_writer.Close()
def testMergeAttributeContainersWithDeserializationError(self): """Tests MergeAttributeContainers with a deserialization error.""" session = sessions.Session() with shared_test_lib.TempDirectory() as temp_directory: task_storage_path = os.path.join(temp_directory, 'task.sqlite') self._CreateTaskStorageFile( session, task_storage_path, self._TEST_EVENTS_WITH_DESERIALIZATION_ERROR) session_storage_path = os.path.join(temp_directory, 'plaso.sqlite') storage_writer = writer.SQLiteStorageFileWriter( session, session_storage_path) test_reader = merge_reader.SQLiteStorageMergeReader( storage_writer, task_storage_path) storage_writer.Open() result = test_reader.MergeAttributeContainers() self.assertTrue(result) storage_writer.Close()