Skip to content

Commit 18a2ce1

Browse files
authored
Merge pull request #907 from onekey-sec/relax-dissect-cstruct-annotation
chore(dissect.cstruct): Make Unblob compatible with version 4.0
2 parents eb8b1b5 + 94f9129 commit 18a2ce1

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ packages = [
1111
[tool.poetry.dependencies]
1212
python = "^3.8"
1313
click = "^8.1.7"
14-
"dissect.cstruct" = "^2.0"
14+
"dissect.cstruct" = ">=2.0,<5.0"
1515
attrs = ">=23.1.0"
1616
structlog = ">=24.1.0"
1717
arpy = "^2.3.0"

unblob/logging.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
from typing import Any
88

99
import structlog
10-
from dissect.cstruct import Instance, dumpstruct
10+
from dissect.cstruct import dumpstruct
11+
12+
try:
13+
# dissect.cstruct >= 4.0
14+
from dissect.cstruct import Structure
15+
except ImportError:
16+
# dissect.cstruct == 2.0
17+
from dissect.cstruct import Instance as Structure
1118

1219

1320
def format_hex(value: int):
@@ -42,7 +49,7 @@ def _format_message(value: Any, extract_root: Path) -> Any:
4249
new_value = value
4350
return new_value.as_posix().encode("utf-8", errors="surrogateescape")
4451

45-
if isinstance(value, Instance):
52+
if isinstance(value, Structure):
4653
return dumpstruct(value, output="string")
4754

4855
if isinstance(value, int):

0 commit comments

Comments
 (0)