Skip to content

Commit

Permalink
Merge pull request #907 from onekey-sec/relax-dissect-cstruct-annotation
Browse files Browse the repository at this point in the history
chore(dissect.cstruct): Make Unblob compatible with version 4.0
  • Loading branch information
vlaci authored Jul 23, 2024
2 parents eb8b1b5 + 94f9129 commit 18a2ce1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ packages = [
[tool.poetry.dependencies]
python = "^3.8"
click = "^8.1.7"
"dissect.cstruct" = "^2.0"
"dissect.cstruct" = ">=2.0,<5.0"
attrs = ">=23.1.0"
structlog = ">=24.1.0"
arpy = "^2.3.0"
Expand Down
11 changes: 9 additions & 2 deletions unblob/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@
from typing import Any

import structlog
from dissect.cstruct import Instance, dumpstruct
from dissect.cstruct import dumpstruct

try:
# dissect.cstruct >= 4.0
from dissect.cstruct import Structure
except ImportError:
# dissect.cstruct == 2.0
from dissect.cstruct import Instance as Structure


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

if isinstance(value, Instance):
if isinstance(value, Structure):
return dumpstruct(value, output="string")

if isinstance(value, int):
Expand Down

0 comments on commit 18a2ce1

Please sign in to comment.