diff --git a/plaso/lib/definitions.py b/plaso/lib/definitions.py index 893c12037b..2ff60aa8ed 100644 --- a/plaso/lib/definitions.py +++ b/plaso/lib/definitions.py @@ -59,8 +59,12 @@ STORAGE_FORMAT_SQLITE = 'sqlite' STORAGE_FORMAT_REDIS = 'redis' -SESSION_STORAGE_FORMATS = frozenset([STORAGE_FORMAT_SQLITE]) -TASK_STORAGE_FORMATS = frozenset([STORAGE_FORMAT_SQLITE, STORAGE_FORMAT_REDIS]) +SESSION_STORAGE_FORMATS = frozenset([ + STORAGE_FORMAT_SQLITE]) + +TASK_STORAGE_FORMATS = frozenset([ + STORAGE_FORMAT_SQLITE, + STORAGE_FORMAT_REDIS]) DEFAULT_STORAGE_FORMAT = STORAGE_FORMAT_SQLITE diff --git a/plaso/storage/factory.py b/plaso/storage/factory.py index 603080d01c..23fbaa1559 100644 --- a/plaso/storage/factory.py +++ b/plaso/storage/factory.py @@ -46,7 +46,7 @@ def CreateStorageReaderForFile(cls, path): opened or the storage format is not supported. """ if sqlite_file.SQLiteStorageFile.CheckSupportedFormat(path): - return sqlite_reader.SQLiteStorageFileReader(path) + return sqlite_reader.SQLiteStorageReader(path) return None @@ -62,7 +62,7 @@ def CreateStorageWriter(cls, storage_format): opened or the storage format is not supported. """ if storage_format == definitions.STORAGE_FORMAT_SQLITE: - return sqlite_writer.SQLiteStorageFileWriter() + return sqlite_writer.SQLiteStorageWriter() if storage_format == definitions.STORAGE_FORMAT_REDIS and redis_writer: return redis_writer.RedisStorageWriter() @@ -81,7 +81,7 @@ def CreateStorageWriterForFile(cls, path): opened or the storage format is not supported. """ if sqlite_file.SQLiteStorageFile.CheckSupportedFormat(path): - return sqlite_writer.SQLiteStorageFileWriter() + return sqlite_writer.SQLiteStorageWriter() return None @@ -99,7 +99,7 @@ def CreateTaskStorageReader(cls, storage_format, task, path): opened or the storage format is not supported. """ if storage_format == definitions.STORAGE_FORMAT_SQLITE: - return sqlite_reader.SQLiteStorageFileReader(path) + return sqlite_reader.SQLiteStorageReader(path) if storage_format == definitions.STORAGE_FORMAT_REDIS and redis_reader: return redis_reader.RedisStorageReader( @@ -119,7 +119,7 @@ def CreateTaskStorageWriter(cls, storage_format): opened or the storage format is not supported. """ if storage_format == definitions.STORAGE_FORMAT_SQLITE: - return sqlite_writer.SQLiteStorageFileWriter( + return sqlite_writer.SQLiteStorageWriter( storage_type=definitions.STORAGE_TYPE_TASK) if storage_format == definitions.STORAGE_FORMAT_REDIS and redis_writer: diff --git a/plaso/storage/redis/reader.py b/plaso/storage/redis/reader.py index b6bb7fdf47..b5f80d5bc4 100644 --- a/plaso/storage/redis/reader.py +++ b/plaso/storage/redis/reader.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- -"""Redis storage reader.""" +"""Redis-based storage reader.""" from plaso.storage import reader from plaso.storage.redis import redis_store class RedisStorageReader(reader.StorageReader): - """Redis storage file reader.""" + """Redis-based storage reader.""" def __init__(self, session_identifier, task_identifier, redis_client=None): - """Initializes a Redis storage reader. + """Initializes a storage reader. Args: session_identifier (str): session identifier. diff --git a/plaso/storage/redis/writer.py b/plaso/storage/redis/writer.py index b96e703335..7435cb9efb 100644 --- a/plaso/storage/redis/writer.py +++ b/plaso/storage/redis/writer.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Storage writer for Redis.""" +"""Redis-based storage writer.""" from plaso.storage import writer from plaso.storage.redis import redis_store diff --git a/plaso/storage/sqlite/reader.py b/plaso/storage/sqlite/reader.py index 9a7e902683..586d50d7c1 100644 --- a/plaso/storage/sqlite/reader.py +++ b/plaso/storage/sqlite/reader.py @@ -1,20 +1,20 @@ # -*- coding: utf-8 -*- -"""SQLite-based storage file reader.""" +"""SQLite-based storage reader.""" from plaso.storage import reader from plaso.storage.sqlite import sqlite_file -class SQLiteStorageFileReader(reader.StorageReader): - """SQLite-based storage file reader.""" +class SQLiteStorageReader(reader.StorageReader): + """SQLite-based storage reader.""" def __init__(self, path): - """Initializes a SQLite-based file storage reader. + """Initializes a storage reader. Args: - path (str): path to the input file. + path (str): path to the input SQLite database. """ - super(SQLiteStorageFileReader, self).__init__() + super(SQLiteStorageReader, self).__init__() self._path = path self._store = sqlite_file.SQLiteStorageFile() self._store.Open(path=path) diff --git a/plaso/storage/sqlite/writer.py b/plaso/storage/sqlite/writer.py index 0de512d8c7..ace20afcc9 100644 --- a/plaso/storage/sqlite/writer.py +++ b/plaso/storage/sqlite/writer.py @@ -1,13 +1,13 @@ # -*- coding: utf-8 -*- -"""Storage writer for SQLite storage files.""" +"""SQLite-based storage writer.""" from plaso.lib import definitions from plaso.storage import writer from plaso.storage.sqlite import sqlite_file -class SQLiteStorageFileWriter(writer.StorageWriter): - """SQLite-based storage file writer.""" +class SQLiteStorageWriter(writer.StorageWriter): + """SQLite-based storage writer.""" def __init__(self, storage_type=definitions.STORAGE_TYPE_SESSION): """Initializes a storage writer. @@ -15,7 +15,7 @@ def __init__(self, storage_type=definitions.STORAGE_TYPE_SESSION): Args: storage_type (Optional[str]): storage type. """ - super(SQLiteStorageFileWriter, self).__init__() + super(SQLiteStorageWriter, self).__init__() self._first_written_event_data_index = 0 self._first_written_event_source_index = 0 self._written_event_data_index = 0 @@ -112,7 +112,7 @@ def Open(self, path=None, **unused_kwargs): """Opens the storage writer. Args: - path (Optional[str]): path to the output file. + path (Optional[str]): path to the output SQLite database. Raises: IOError: if the storage writer is already opened. diff --git a/tests/multi_process/extraction_engine.py b/tests/multi_process/extraction_engine.py index 922551d4d6..0b311beab7 100644 --- a/tests/multi_process/extraction_engine.py +++ b/tests/multi_process/extraction_engine.py @@ -49,7 +49,7 @@ def testProcessSource(self): with shared_test_lib.TempDirectory() as temp_directory: temp_file = os.path.join(temp_directory, 'storage.plaso') - storage_writer = sqlite_writer.SQLiteStorageFileWriter() + storage_writer = sqlite_writer.SQLiteStorageWriter() storage_writer.Open(path=temp_file) try: diff --git a/tests/storage/factory.py b/tests/storage/factory.py index 08158a95f4..43b4dd41bd 100644 --- a/tests/storage/factory.py +++ b/tests/storage/factory.py @@ -21,7 +21,7 @@ def testCreateStorageReaderForFile(self): storage_reader = factory.StorageFactory.CreateStorageReaderForFile( test_file_path) - self.assertIsInstance(storage_reader, sqlite_reader.SQLiteStorageFileReader) + self.assertIsInstance(storage_reader, sqlite_reader.SQLiteStorageReader) def testCreateStorageWriterForFile(self): """Test the CreateStorageWriterForFile function.""" @@ -30,7 +30,7 @@ def testCreateStorageWriterForFile(self): storage_reader = factory.StorageFactory.CreateStorageWriterForFile( test_file_path) - self.assertIsInstance(storage_reader, sqlite_writer.SQLiteStorageFileWriter) + self.assertIsInstance(storage_reader, sqlite_writer.SQLiteStorageWriter) if __name__ == '__main__': diff --git a/tests/storage/sqlite/reader.py b/tests/storage/sqlite/reader.py index 0343321dfc..5fb0032778 100644 --- a/tests/storage/sqlite/reader.py +++ b/tests/storage/sqlite/reader.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -"""Tests for the SQLite-based storage file reader.""" +"""Tests for the SQLite-based storage reader.""" import unittest @@ -9,13 +9,13 @@ from tests.storage import test_lib -class SQLiteStorageFileReaderTest(test_lib.StorageTestCase): - """Tests for the SQLite-based storage file reader.""" +class SQLiteStorageReaderTest(test_lib.StorageTestCase): + """Tests for the SQLite-based storage reader.""" def testInitialization(self): """Tests the __init__ function.""" test_path = self._GetTestFilePath(['pinfo_test.plaso']) - test_reader = reader.SQLiteStorageFileReader(test_path) + test_reader = reader.SQLiteStorageReader(test_path) self.assertIsNotNone(test_reader) diff --git a/tests/storage/sqlite/writer.py b/tests/storage/sqlite/writer.py index 050d17756c..fedc26ca23 100644 --- a/tests/storage/sqlite/writer.py +++ b/tests/storage/sqlite/writer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -"""Tests for the fake storage writer.""" +"""Tests for the SQLite-based storage writer.""" import os import unittest @@ -14,8 +14,8 @@ from tests.containers import test_lib as containers_test_lib -class SQLiteStorageFileWriterTest(test_lib.StorageTestCase): - """Tests for the fake storage writer.""" +class SQLiteStorageWriterTest(test_lib.StorageTestCase): + """Tests for the SQLite-based storage writer.""" # pylint: disable=protected-access @@ -23,7 +23,7 @@ def _AddTestEvents(self, storage_writer): """Adds tests events to the storage writer. Args: - storage_writer (SQLiteStorageFileWriter): storage writer. + storage_writer (SQLiteStorageWriter): storage writer. Returns: list[EventObject]: test events. @@ -49,7 +49,7 @@ def testAddAttributeContainer(self): with shared_test_lib.TempDirectory() as temp_directory: test_path = os.path.join(temp_directory, 'plaso.sqlite') - storage_writer = sqlite_writer.SQLiteStorageFileWriter() + storage_writer = sqlite_writer.SQLiteStorageWriter() storage_writer.Open(path=test_path) try: @@ -73,7 +73,7 @@ def testAddOrUpdateEventTag(self): """Tests the AddOrUpdateEventTag function.""" with shared_test_lib.TempDirectory() as temp_directory: test_path = os.path.join(temp_directory, 'plaso.sqlite') - storage_writer = sqlite_writer.SQLiteStorageFileWriter() + storage_writer = sqlite_writer.SQLiteStorageWriter() storage_writer.Open(path=test_path) try: @@ -134,7 +134,7 @@ def testGetSortedEvents(self): """Tests the GetSortedEvents function.""" with shared_test_lib.TempDirectory() as temp_directory: test_path = os.path.join(temp_directory, 'plaso.sqlite') - storage_writer = sqlite_writer.SQLiteStorageFileWriter() + storage_writer = sqlite_writer.SQLiteStorageWriter() storage_writer.Open(path=test_path) try: @@ -152,14 +152,14 @@ def testOpenClose(self): """Tests the Open and Close functions.""" with shared_test_lib.TempDirectory() as temp_directory: test_path = os.path.join(temp_directory, 'plaso.sqlite') - storage_writer = sqlite_writer.SQLiteStorageFileWriter() + storage_writer = sqlite_writer.SQLiteStorageWriter() storage_writer.Open(path=test_path) storage_writer.Close() storage_writer.Open(path=test_path) storage_writer.Close() - storage_writer = sqlite_writer.SQLiteStorageFileWriter( + storage_writer = sqlite_writer.SQLiteStorageWriter( storage_type=definitions.STORAGE_TYPE_TASK) storage_writer.Open(path=test_path) storage_writer.Close()