dissect.cstruct 4.7.dev1__tar.gz → 4.8.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/PKG-INFO +1 -1
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/PKG-INFO +1 -1
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/SOURCES.txt +1 -0
- dissect_cstruct-4.8.dev1/tests/conftest.py +31 -0
- dissect_cstruct-4.8.dev1/tests/test_benchmark.py +87 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tox.ini +11 -1
- dissect_cstruct-4.7.dev1/tests/conftest.py +0 -13
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/.git-blame-ignore-revs +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/.gitattributes +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/CHANGELOG.md +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/COPYRIGHT +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/LICENSE +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/MANIFEST.in +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/README.md +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/__init__.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/bitbuffer.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/compiler.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/cstruct.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/exceptions.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/expression.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/parser.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/tools/__init__.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/tools/stubgen.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/__init__.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/base.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/char.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/enum.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/flag.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/int.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/leb128.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/packed.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/pointer.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/structure.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/void.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/types/wchar.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect/cstruct/utils.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/entry_points.txt +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/requires.txt +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/top_level.txt +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/examples/disk.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/examples/mirai.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/examples/pe.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/examples/protobuf.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/examples/secdesc.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/pyproject.toml +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/setup.cfg +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/__init__.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/_data/testdef.txt +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/_docs/Makefile +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/_docs/__init__.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/_docs/conf.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/_docs/index.rst +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_align.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_annotations.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_basic.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_bitbuffer.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_bitfield.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_compiler.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_ctypes.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_expression.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_parser.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_tools_stubgen.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_base.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_char.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_custom.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_enum.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_flag.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_int.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_leb128.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_packed.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_pointer.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_structure.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_union.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_void.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_types_wchar.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/test_utils.py +0 -0
- {dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/tests/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.8.dev1
|
|
4
4
|
Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
|
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.8.dev1
|
|
4
4
|
Summary: A Dissect module implementing a parser for C-like structures: structure parsing in Python made easy
|
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import importlib.util
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from dissect.cstruct.cstruct import cstruct
|
|
8
|
+
|
|
9
|
+
HAS_BENCHMARK = importlib.util.find_spec("pytest_benchmark") is not None
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def pytest_configure(config: pytest.Config) -> None:
|
|
13
|
+
if not HAS_BENCHMARK:
|
|
14
|
+
# If we don't have pytest-benchmark (or pytest-codspeed) installed, register the benchmark marker ourselves
|
|
15
|
+
# to avoid pytest warnings
|
|
16
|
+
config.addinivalue_line("markers", "benchmark: mark test for benchmarking (requires pytest-benchmark)")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def pytest_runtest_setup(item: pytest.Item) -> None:
|
|
20
|
+
if not HAS_BENCHMARK and item.get_closest_marker("benchmark") is not None:
|
|
21
|
+
pytest.skip("pytest-benchmark is not installed")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@pytest.fixture
|
|
25
|
+
def cs() -> cstruct:
|
|
26
|
+
return cstruct()
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.fixture(params=[True, False], ids=["compiled", "interpreted"])
|
|
30
|
+
def compiled(request: pytest.FixtureRequest) -> bool:
|
|
31
|
+
return request.param
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from pytest_benchmark.fixture import BenchmarkFixture
|
|
9
|
+
|
|
10
|
+
from dissect.cstruct.cstruct import cstruct
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@pytest.mark.benchmark
|
|
14
|
+
def test_benchmark_basic(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
|
|
15
|
+
"""Benchmark the parsing of a simple struct with both the compiled and interpreted backends."""
|
|
16
|
+
cdef = """
|
|
17
|
+
struct test {
|
|
18
|
+
uint32 a;
|
|
19
|
+
uint64 b;
|
|
20
|
+
uint16 c;
|
|
21
|
+
uint8 d;
|
|
22
|
+
};
|
|
23
|
+
"""
|
|
24
|
+
cs.load(cdef, compiled=compiled)
|
|
25
|
+
|
|
26
|
+
benchmark(lambda: cs.test(b"\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x03\x00\x04"))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@pytest.mark.benchmark
|
|
30
|
+
def test_benchmark_union(cs: cstruct, compiled: bool, benchmark: BenchmarkFixture) -> None:
|
|
31
|
+
"""Benchmark the parsing of a simple union with both the compiled and interpreted backends."""
|
|
32
|
+
cdef = """
|
|
33
|
+
union test {
|
|
34
|
+
uint32 a;
|
|
35
|
+
uint64 b;
|
|
36
|
+
uint16 c;
|
|
37
|
+
uint8 d;
|
|
38
|
+
};
|
|
39
|
+
"""
|
|
40
|
+
cs.load(cdef, compiled=compiled)
|
|
41
|
+
|
|
42
|
+
benchmark(lambda: cs.test(b"\x01\x02\x03\x04\x05\x06\x07\x08"))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@pytest.mark.benchmark
|
|
46
|
+
def test_benchmark_attribute_access(cs: cstruct, benchmark: BenchmarkFixture) -> None:
|
|
47
|
+
"""Benchmark the attribute access of a parsed struct."""
|
|
48
|
+
cdef = """
|
|
49
|
+
struct test {
|
|
50
|
+
uint32 a;
|
|
51
|
+
uint64 b;
|
|
52
|
+
uint16 c;
|
|
53
|
+
uint8 d;
|
|
54
|
+
};
|
|
55
|
+
"""
|
|
56
|
+
cs.load(cdef)
|
|
57
|
+
obj = cs.test(b"\x01\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x03\x00\x04")
|
|
58
|
+
|
|
59
|
+
benchmark(lambda: (obj.a, obj.b, obj.c, obj.d))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@pytest.mark.benchmark
|
|
63
|
+
def test_benchmark_getattr_constants(cs: cstruct, benchmark: BenchmarkFixture) -> None:
|
|
64
|
+
"""Benchmark the resolving of constants on the cstruct instance."""
|
|
65
|
+
cdef = """
|
|
66
|
+
#define CONST1 1
|
|
67
|
+
"""
|
|
68
|
+
cs.load(cdef)
|
|
69
|
+
|
|
70
|
+
benchmark(lambda: cs.CONST1)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.benchmark
|
|
74
|
+
def test_benchmark_getattr_types(cs: cstruct, benchmark: BenchmarkFixture) -> None:
|
|
75
|
+
"""Benchmark the resolving of types on the cstruct instance."""
|
|
76
|
+
benchmark(lambda: cs.uint8)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@pytest.mark.benchmark
|
|
80
|
+
def test_benchmark_getattr_typedefs(cs: cstruct, benchmark: BenchmarkFixture) -> None:
|
|
81
|
+
"""Benchmark the resolving of typedefs on the cstruct instance."""
|
|
82
|
+
cdef = """
|
|
83
|
+
typedef uint8 my_uint8;
|
|
84
|
+
"""
|
|
85
|
+
cs.load(cdef)
|
|
86
|
+
|
|
87
|
+
benchmark(lambda: cs.my_uint8)
|
|
@@ -18,10 +18,20 @@ deps =
|
|
|
18
18
|
coverage
|
|
19
19
|
dependency_groups = test
|
|
20
20
|
commands =
|
|
21
|
-
pytest --basetemp="{envtmpdir}" {posargs:--color=yes --cov=dissect --cov-report=term-missing -v tests}
|
|
21
|
+
pytest --basetemp="{envtmpdir}" --import-mode="append" {posargs:--color=yes --cov=dissect --cov-report=term-missing -v tests}
|
|
22
22
|
coverage report
|
|
23
23
|
coverage xml
|
|
24
24
|
|
|
25
|
+
[testenv:benchmark]
|
|
26
|
+
deps =
|
|
27
|
+
pytest-benchmark
|
|
28
|
+
pytest-codspeed
|
|
29
|
+
dependency_groups = test
|
|
30
|
+
passenv =
|
|
31
|
+
CODSPEED_ENV
|
|
32
|
+
commands =
|
|
33
|
+
pytest --basetemp="{envtmpdir}" --import-mode="append" -m benchmark {posargs:--color=yes -v tests}
|
|
34
|
+
|
|
25
35
|
[testenv:build]
|
|
26
36
|
package = skip
|
|
27
37
|
dependency_groups = build
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.7.dev1 → dissect_cstruct-4.8.dev1}/dissect.cstruct.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|