Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Worked on JSON serializer helper #65

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions .github/workflows/test_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install dependencies
run: |
dnf copr -y enable @gift/dev
dnf install -y @development-tools python3 python3-devel python3-pyyaml python3-setuptools
dnf install -y @development-tools python3 python3-build python3-devel python3-pyyaml python3-setuptools python3-wheel
- name: Run tests
env:
LANG: C.utf8
Expand All @@ -27,16 +27,12 @@ jobs:
- name: Run end-to-end tests
run: |
if test -f tests/end-to-end.py; then PYTHONPATH=. python3 ./tests/end-to-end.py --debug -c config/end-to-end.ini; fi
- name: Build source distribution
- name: Build source distribution (sdist)
run: |
python3 ./setup.py sdist
- name: Build binary distribution
python3 -m build --no-isolation --sdist
- name: Build binary distribution (wheel)
run: |
python3 ./setup.py bdist
- name: Run build and install test
run: |
python3 ./setup.py build
python3 ./setup.py install
python3 -m build --no-isolation --wheel
test_ubuntu:
runs-on: ubuntu-latest
strategy:
Expand All @@ -58,7 +54,7 @@ jobs:
run: |
add-apt-repository -y ppa:gift/dev
apt-get update -q
apt-get install -y build-essential python3 python3-dev python3-distutils python3-pip python3-setuptools python3-wheel python3-yaml
apt-get install -y build-essential python3 python3-build python3-dev python3-distutils python3-pip python3-setuptools python3-wheel python3-yaml
- name: Run tests
env:
LANG: en_US.UTF-8
Expand All @@ -69,16 +65,9 @@ jobs:
LANG: en_US.UTF-8
run: |
if test -f tests/end-to-end.py; then PYTHONPATH=. python3 ./tests/end-to-end.py --debug -c config/end-to-end.ini; fi
- name: Update setuptools
run: |
python3 -m pip install -U setuptools
- name: Build source distribution
run: |
python3 ./setup.py sdist
- name: Build binary distribution
- name: Build source distribution (sdist)
run: |
python3 ./setup.py bdist
- name: Run build and install test
python3 -m build --no-isolation --sdist
- name: Build binary distribution (wheel)
run: |
python3 ./setup.py build
python3 ./setup.py install
python3 -m build --no-isolation --wheel
2 changes: 1 addition & 1 deletion acstore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
to read and write plaso storage files.
"""

__version__ = '20240316'
__version__ = '20240406'
12 changes: 12 additions & 0 deletions acstore/helpers/json_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ def ConvertJSONToAttributeContainer(cls, json_dict):
attribute_container = cls._CONTAINERS_MANAGER.CreateAttributeContainer(
container_type)

try:
schema = cls._CONTAINERS_MANAGER.GetSchema(container_type)
except ValueError:
schema = {}

supported_attribute_names = attribute_container.GetAttributeNames()
for attribute_name, attribute_value in json_dict.items():
if attribute_name in ('__container_type__', '__type__'):
Expand All @@ -98,6 +103,13 @@ def ConvertJSONToAttributeContainer(cls, json_dict):
if attribute_name not in supported_attribute_names:
continue

data_type = schema.get(attribute_name, None)
serializer = schema_helper.SchemaHelper.GetAttributeSerializer(
data_type, 'json')

if serializer:
attribute_value = serializer.DeserializeValue(attribute_value)

setattr(attribute_container, attribute_name, attribute_value)

return attribute_container
6 changes: 3 additions & 3 deletions acstore/sqlite_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ def _WriteExistingAttributeContainer(self, container):
f'Unsupported attribute container type: {container.CONTAINER_TYPE:s}')

column_names = []
values = []
row_values = []
for name, data_type in sorted(schema.items()):
attribute_value = getattr(container, name, None)
try:
Expand All @@ -679,7 +679,7 @@ def _WriteExistingAttributeContainer(self, container):
f'{data_type:s}'))

column_names.append(f'{name:s} = ?')
values.append(row_value)
row_values.append(row_value)

column_names_string = ', '.join(column_names)

Expand All @@ -690,7 +690,7 @@ def _WriteExistingAttributeContainer(self, container):
self._storage_profiler.StartTiming('write_existing')

try:
self._cursor.execute(query, values)
self._cursor.execute(query, row_values)

except (sqlite3.InterfaceError, sqlite3.OperationalError) as exception:
raise IOError((
Expand Down
4 changes: 2 additions & 2 deletions config/dpkg/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
acstore (20240316-1) unstable; urgency=low
acstore (20240406-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline maintainers <[email protected]> Sat, 16 Mar 2024 22:45:43 +0100
-- Log2Timeline maintainers <[email protected]> Sat, 06 Apr 2024 05:54:23 +0200
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = acstore
version = 20240316
version = 20240406
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
Expand Down
Loading