diff --git a/acstore/__init__.py b/acstore/__init__.py index 523f88a..0cee674 100644 --- a/acstore/__init__.py +++ b/acstore/__init__.py @@ -5,4 +5,4 @@ to read and write plaso storage files. """ -__version__ = '20240406' +__version__ = '20240407' diff --git a/acstore/helpers/json_serializer.py b/acstore/helpers/json_serializer.py index 2632aad..84ba1ca 100644 --- a/acstore/helpers/json_serializer.py +++ b/acstore/helpers/json_serializer.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """Attribute container JSON serializer.""" +from acstore.containers import interface as containers_interface from acstore.containers import manager as containers_manager from acstore.helpers import schema as schema_helper @@ -45,11 +46,14 @@ def ConvertAttributeContainerToJSON(cls, attribute_container): for attribute_name, attribute_value in attribute_container.GetAttributes(): data_type = schema.get(attribute_name, None) - serializer = schema_helper.SchemaHelper.GetAttributeSerializer( - data_type, 'json') - - if serializer: - attribute_value = serializer.SerializeValue(attribute_value) + if data_type == 'AttributeContainerIdentifier' and isinstance( + attribute_value, containers_interface.AttributeContainerIdentifier): + attribute_value = attribute_value.CopyToString() + else: + serializer = schema_helper.SchemaHelper.GetAttributeSerializer( + data_type, 'json') + if serializer: + attribute_value = serializer.SerializeValue(attribute_value) # JSON will not serialize certain runtime types like set, therefore # these are cast to list first. @@ -104,11 +108,15 @@ def ConvertJSONToAttributeContainer(cls, json_dict): continue data_type = schema.get(attribute_name, None) - serializer = schema_helper.SchemaHelper.GetAttributeSerializer( - data_type, 'json') - - if serializer: - attribute_value = serializer.DeserializeValue(attribute_value) + if data_type == 'AttributeContainerIdentifier': + identifier = containers_interface.AttributeContainerIdentifier() + identifier.CopyFromString(attribute_value) + attribute_value = identifier + else: + serializer = schema_helper.SchemaHelper.GetAttributeSerializer( + data_type, 'json') + if serializer: + attribute_value = serializer.DeserializeValue(attribute_value) setattr(attribute_container, attribute_name, attribute_value) diff --git a/acstore/sqlite_store.py b/acstore/sqlite_store.py index 6891de6..9289ebe 100644 --- a/acstore/sqlite_store.py +++ b/acstore/sqlite_store.py @@ -180,23 +180,15 @@ class SQLiteAttributeContainerStore( # The earliest format version, stored in-file, that this class # is able to append (write). - _APPEND_COMPATIBLE_FORMAT_VERSION = 20221023 + _APPEND_COMPATIBLE_FORMAT_VERSION = 20230312 # The earliest format version, stored in-file, that this class # is able to upgrade (write new format features). - _UPGRADE_COMPATIBLE_FORMAT_VERSION = 20221023 + _UPGRADE_COMPATIBLE_FORMAT_VERSION = 20230312 # The earliest format version, stored in-file, that this class # is able to read. - _READ_COMPATIBLE_FORMAT_VERSION = 20221023 - - # TODO: kept for backwards compatibility. - _CONTAINER_SCHEMA_TO_SQLITE_TYPE_MAPPINGS = { - 'AttributeContainerIdentifier': 'TEXT', - 'bool': 'INTEGER', - 'int': 'INTEGER', - 'str': 'TEXT', - 'timestamp': 'BIGINT'} + _READ_COMPATIBLE_FORMAT_VERSION = 20230312 _CREATE_METADATA_TABLE_QUERY = ( 'CREATE TABLE metadata (key TEXT, value TEXT);') diff --git a/config/dpkg/changelog b/config/dpkg/changelog index 71fbb16..f39bce2 100644 --- a/config/dpkg/changelog +++ b/config/dpkg/changelog @@ -1,5 +1,5 @@ -acstore (20240406-1) unstable; urgency=low +acstore (20240407-1) unstable; urgency=low * Auto-generated - -- Log2Timeline maintainers Sat, 06 Apr 2024 05:54:23 +0200 + -- Log2Timeline maintainers Sun, 07 Apr 2024 07:12:15 +0200 diff --git a/setup.cfg b/setup.cfg index 59b1cfb..3533d9c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = acstore -version = 20240406 +version = 20240407 description = Attribute Container Storage (ACStore). long_description = ACStore, or Attribute Container Storage, provides a stand-alone implementation to read and write attribute container storage files. long_description_content_type = text/plain