dissect.cstruct 4.8.dev1__tar.gz → 4.8.dev3__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.8.dev1 → dissect_cstruct-4.8.dev3}/PKG-INFO +1 -1
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/PKG-INFO +1 -1
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/pyproject.toml +1 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_annotations.py +1 -1
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_benchmark.py +89 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/.git-blame-ignore-revs +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/.gitattributes +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/CHANGELOG.md +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/COPYRIGHT +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/LICENSE +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/MANIFEST.in +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/README.md +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/__init__.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/bitbuffer.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/compiler.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/cstruct.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/exceptions.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/expression.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/parser.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/tools/__init__.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/tools/stubgen.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/__init__.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/base.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/char.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/enum.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/flag.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/int.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/leb128.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/packed.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/pointer.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/structure.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/void.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/wchar.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/utils.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/entry_points.txt +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/requires.txt +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/top_level.txt +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/disk.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/mirai.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/pe.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/protobuf.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/secdesc.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/setup.cfg +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/__init__.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_data/testdef.txt +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_docs/Makefile +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_docs/__init__.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_docs/conf.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_docs/index.rst +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/conftest.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_align.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_basic.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_bitbuffer.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_bitfield.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_compiler.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_ctypes.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_expression.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_parser.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_tools_stubgen.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_base.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_char.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_custom.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_enum.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_flag.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_int.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_leb128.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_packed.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_pointer.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_structure.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_union.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_void.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_wchar.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_utils.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/utils.py +0 -0
- {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.cstruct
|
|
3
|
-
Version: 4.8.
|
|
3
|
+
Version: 4.8.dev3
|
|
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.8.
|
|
3
|
+
Version: 4.8.dev3
|
|
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
|
|
@@ -21,7 +21,7 @@ def test_cstruct_type_annotation(name: str, monkeypatch: pytest.MonkeyPatch) ->
|
|
|
21
21
|
for module in [module for module in sys.modules if module in ("dissect.cstruct.cstruct")]:
|
|
22
22
|
monkeypatch.delitem(sys.modules, module)
|
|
23
23
|
|
|
24
|
-
from dissect.cstruct import cstruct
|
|
24
|
+
from dissect.cstruct import cstruct
|
|
25
25
|
|
|
26
26
|
if name.startswith("__"):
|
|
27
27
|
name = f"_cstruct{name}"
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
from functools import partial
|
|
3
4
|
from typing import TYPE_CHECKING
|
|
4
5
|
|
|
5
6
|
import pytest
|
|
6
7
|
|
|
8
|
+
from dissect.cstruct.expression import Expression
|
|
9
|
+
|
|
7
10
|
if TYPE_CHECKING:
|
|
8
11
|
from pytest_benchmark.fixture import BenchmarkFixture
|
|
9
12
|
|
|
@@ -85,3 +88,89 @@ def test_benchmark_getattr_typedefs(cs: cstruct, benchmark: BenchmarkFixture) ->
|
|
|
85
88
|
cs.load(cdef)
|
|
86
89
|
|
|
87
90
|
benchmark(lambda: cs.my_uint8)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@pytest.mark.benchmark
|
|
94
|
+
def test_benchmark_expression_parse(cs: cstruct, benchmark: BenchmarkFixture) -> None:
|
|
95
|
+
"""Benchmark the parsing of expressions."""
|
|
96
|
+
cs.load("#define a 5\n#define b 10")
|
|
97
|
+
|
|
98
|
+
benchmark(lambda: Expression("a * 2 + b * (3 + 4) >> 1"))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@pytest.mark.benchmark
|
|
102
|
+
def test_benchmark_expression_evaluate(cs: cstruct, benchmark: BenchmarkFixture) -> None:
|
|
103
|
+
"""Benchmark the evaluation of expressions."""
|
|
104
|
+
cs.load("#define a 5\n#define b 10")
|
|
105
|
+
|
|
106
|
+
expression = Expression("a * 2 + b * (3 + 4) >> 1")
|
|
107
|
+
benchmark(lambda: expression.evaluate(cs))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@pytest.mark.benchmark
|
|
111
|
+
def test_benchmark_expression_parse_and_evaluate(cs: cstruct, benchmark: BenchmarkFixture) -> None:
|
|
112
|
+
"""Benchmark the parsing and evaluation of expressions."""
|
|
113
|
+
cs.load("#define a 5\n#define b 10")
|
|
114
|
+
|
|
115
|
+
benchmark(lambda: Expression("a * 2 + b * (3 + 4) >> 1").evaluate(cs))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
_BENCHMARK_CDEF = """
|
|
119
|
+
struct SECURITY_DESCRIPTOR {
|
|
120
|
+
uint8 Revision;
|
|
121
|
+
uint8 Sbz1;
|
|
122
|
+
uint16 Control;
|
|
123
|
+
uint32 OffsetOwner;
|
|
124
|
+
uint32 OffsetGroup;
|
|
125
|
+
uint32 OffsetSacl;
|
|
126
|
+
uint32 OffsetDacl;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
struct LDAP_SID_IDENTIFIER_AUTHORITY {
|
|
130
|
+
char Value[6];
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
struct LDAP_SID {
|
|
134
|
+
uint8 Revision;
|
|
135
|
+
uint8 SubAuthorityCount;
|
|
136
|
+
LDAP_SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
|
|
137
|
+
uint32 SubAuthority[SubAuthorityCount];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
struct ACL {
|
|
141
|
+
uint8 AclRevision;
|
|
142
|
+
uint8 Sbz1;
|
|
143
|
+
uint16 AclSize;
|
|
144
|
+
uint16 AceCount;
|
|
145
|
+
uint16 Sbz2;
|
|
146
|
+
char Data[AclSize - 8];
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
struct ACE {
|
|
150
|
+
uint8 AceType;
|
|
151
|
+
uint8 AceFlags;
|
|
152
|
+
uint16 AceSize;
|
|
153
|
+
char Data[AceSize - 4];
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
struct ACCESS_ALLOWED_ACE {
|
|
157
|
+
uint16 Mask;
|
|
158
|
+
LDAP_SID Sid;
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
struct ACCESS_ALLOWED_OBJECT_ACE {
|
|
162
|
+
uint32 Mask;
|
|
163
|
+
uint32 Flags;
|
|
164
|
+
char ObjectType[(Flags & 1) * 16];
|
|
165
|
+
char InheritedObjectType[(Flags & 2) * 8];
|
|
166
|
+
LDAP_SID Sid;
|
|
167
|
+
};
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@pytest.mark.benchmark
|
|
172
|
+
def test_benchmark_lexer_and_parser(cs: cstruct, benchmark: BenchmarkFixture) -> None:
|
|
173
|
+
"""Benchmark tokenizing and parsing a realistic set of struct definitions."""
|
|
174
|
+
cs.add_type = partial(cs.add_type, replace=True)
|
|
175
|
+
|
|
176
|
+
benchmark(lambda: cs.load(_BENCHMARK_CDEF))
|
|
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
|
{dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/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
|