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.
Files changed (77) hide show
  1. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/PKG-INFO +1 -1
  2. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/PKG-INFO +1 -1
  3. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/pyproject.toml +1 -0
  4. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_annotations.py +1 -1
  5. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_benchmark.py +89 -0
  6. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/.git-blame-ignore-revs +0 -0
  7. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/.gitattributes +0 -0
  8. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/CHANGELOG.md +0 -0
  9. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/COPYRIGHT +0 -0
  10. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/LICENSE +0 -0
  11. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/MANIFEST.in +0 -0
  12. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/README.md +0 -0
  13. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/__init__.py +0 -0
  14. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/bitbuffer.py +0 -0
  15. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/compiler.py +0 -0
  16. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/cstruct.py +0 -0
  17. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/exceptions.py +0 -0
  18. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/expression.py +0 -0
  19. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/parser.py +0 -0
  20. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/tools/__init__.py +0 -0
  21. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/tools/stubgen.py +0 -0
  22. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/__init__.py +0 -0
  23. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/base.py +0 -0
  24. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/char.py +0 -0
  25. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/enum.py +0 -0
  26. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/flag.py +0 -0
  27. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/int.py +0 -0
  28. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/leb128.py +0 -0
  29. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/packed.py +0 -0
  30. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/pointer.py +0 -0
  31. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/structure.py +0 -0
  32. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/void.py +0 -0
  33. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/types/wchar.py +0 -0
  34. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect/cstruct/utils.py +0 -0
  35. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/SOURCES.txt +0 -0
  36. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/dependency_links.txt +0 -0
  37. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/entry_points.txt +0 -0
  38. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/requires.txt +0 -0
  39. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/dissect.cstruct.egg-info/top_level.txt +0 -0
  40. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/disk.py +0 -0
  41. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/mirai.py +0 -0
  42. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/pe.py +0 -0
  43. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/protobuf.py +0 -0
  44. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/examples/secdesc.py +0 -0
  45. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/setup.cfg +0 -0
  46. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/__init__.py +0 -0
  47. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_data/testdef.txt +0 -0
  48. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_docs/Makefile +0 -0
  49. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_docs/__init__.py +0 -0
  50. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_docs/conf.py +0 -0
  51. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/_docs/index.rst +0 -0
  52. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/conftest.py +0 -0
  53. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_align.py +0 -0
  54. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_basic.py +0 -0
  55. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_bitbuffer.py +0 -0
  56. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_bitfield.py +0 -0
  57. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_compiler.py +0 -0
  58. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_ctypes.py +0 -0
  59. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_expression.py +0 -0
  60. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_parser.py +0 -0
  61. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_tools_stubgen.py +0 -0
  62. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_base.py +0 -0
  63. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_char.py +0 -0
  64. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_custom.py +0 -0
  65. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_enum.py +0 -0
  66. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_flag.py +0 -0
  67. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_int.py +0 -0
  68. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_leb128.py +0 -0
  69. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_packed.py +0 -0
  70. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_pointer.py +0 -0
  71. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_structure.py +0 -0
  72. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_union.py +0 -0
  73. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_void.py +0 -0
  74. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_types_wchar.py +0 -0
  75. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/test_utils.py +0 -0
  76. {dissect_cstruct-4.8.dev1 → dissect_cstruct-4.8.dev3}/tests/utils.py +0 -0
  77. {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.dev1
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.dev1
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
@@ -106,6 +106,7 @@ select = [
106
106
  ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM105", "TRY003"]
107
107
 
108
108
  [tool.ruff.lint.per-file-ignores]
109
+ "tests/**" = ["S101", "PLC0415"]
109
110
  "tests/_docs/**" = ["INP001"]
110
111
 
111
112
  [tool.ruff.lint.isort]
@@ -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 # noqa: PLC0415
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))