Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with cstruct v4 #37

Merged
merged 2 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions dissect/hypervisor/backup/c_vma.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dissect import cstruct
from dissect.cstruct import cstruct

vma_def = """
#define VMA_BLOCK_BITS 12
Expand Down Expand Up @@ -53,8 +53,7 @@
};
"""

c_vma = cstruct.cstruct(endian=">")
c_vma.load(vma_def)
c_vma = cstruct(endian=">").load(vma_def)


VMA_MAGIC = b"VMA\x00"
Expand Down
5 changes: 2 additions & 3 deletions dissect/hypervisor/descriptor/c_hyperv.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dissect import cstruct
from dissect.cstruct import cstruct

hyperv_def = """
/* ======== File header ======== */
Expand Down Expand Up @@ -112,8 +112,7 @@
};
"""

c_hyperv = cstruct.cstruct()
c_hyperv.load(hyperv_def)
c_hyperv = cstruct().load(hyperv_def)

ObjectEntryType = c_hyperv.ObjectEntryType
KeyDataType = c_hyperv.KeyDataType
Expand Down
5 changes: 2 additions & 3 deletions dissect/hypervisor/disk/c_hdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# - https://github.com/qemu/qemu/blob/master/docs/interop/parallels.txt


from dissect import cstruct
from dissect.cstruct import cstruct

hdd_def = """
/* Compressed disk v1 signature */
Expand Down Expand Up @@ -62,7 +62,6 @@
};
"""

c_hdd = cstruct.cstruct()
c_hdd.load(hdd_def)
c_hdd = cstruct().load(hdd_def)

SECTOR_SIZE = c_hdd.SECTOR_SIZE
5 changes: 2 additions & 3 deletions dissect/hypervisor/disk/c_qcow2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dissect import cstruct
from dissect.cstruct import cstruct

qcow2_def = """
#define MIN_CLUSTER_BITS 9
Expand Down Expand Up @@ -136,8 +136,7 @@
};
"""

c_qcow2 = cstruct.cstruct(endian=">")
c_qcow2.load(qcow2_def)
c_qcow2 = cstruct(endian=">").load(qcow2_def)

QCOW2_MAGIC = 0x514649FB
QCOW2_MAGIC_BYTES = c_qcow2.uint32.dumps(QCOW2_MAGIC)
Expand Down
5 changes: 2 additions & 3 deletions dissect/hypervisor/disk/c_vdi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dissect import cstruct
from dissect.cstruct import cstruct

# https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Storage/VDICore.h
# https://forums.virtualbox.org/viewtopic.php?t=8046
Expand Down Expand Up @@ -81,8 +81,7 @@
};
"""

c_vdi = cstruct.cstruct()
c_vdi.load(vdi_def)
c_vdi = cstruct().load(vdi_def)

VDI_SIGNATURE = 0xBEDA107F

Expand Down
9 changes: 4 additions & 5 deletions dissect/hypervisor/disk/c_vhd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from dissect import cstruct
from dissect.cstruct import cstruct

vhd_def = """
struct footer {
Expand Down Expand Up @@ -38,14 +38,13 @@
uint32 checksum;
char parent_unique_id[16];
uint32 parent_timestamp;
uint32 reserved;
uint32 reserved1;
char parent_unicode_name[512];
parent_locator parent_locators[8];
char reserved[256];
char reserved2[256];
};
"""

c_vhd = cstruct.cstruct(endian=">")
c_vhd.load(vhd_def)
c_vhd = cstruct(endian=">").load(vhd_def)

SECTOR_SIZE = 512
5 changes: 2 additions & 3 deletions dissect/hypervisor/disk/c_vhdx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from uuid import UUID

from dissect import cstruct
from dissect.cstruct import cstruct

vhdx_def = """
#define PAYLOAD_BLOCK_NOT_PRESENT 0
Expand Down Expand Up @@ -99,8 +99,7 @@
};
"""

c_vhdx = cstruct.cstruct()
c_vhdx.load(vhdx_def)
c_vhdx = cstruct().load(vhdx_def)

ALIGNMENT = 64 * 1024
MB = 1024 * 1024
Expand Down
5 changes: 2 additions & 3 deletions dissect/hypervisor/disk/c_vmdk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import struct

from dissect import cstruct
from dissect.cstruct import cstruct

vmdk_def = """
typedef struct {
Expand Down Expand Up @@ -132,8 +132,7 @@
#define GRAIN_MARKER_PROGRESS 4
"""

c_vmdk = cstruct.cstruct()
c_vmdk.load(vmdk_def)
c_vmdk = cstruct().load(vmdk_def)

SECTOR_SIZE = 512

Expand Down
5 changes: 2 additions & 3 deletions dissect/hypervisor/util/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
except ImportError:
HAS_PYCRYPTODOME = False

from dissect import cstruct
from dissect.cstruct import cstruct
from dissect.util.stream import RangeStream

c_def = """
Expand Down Expand Up @@ -69,8 +69,7 @@
Bytes = 0xC
};
"""
c_envelope = cstruct.cstruct()
c_envelope.load(c_def)
c_envelope = cstruct().load(c_def)

FILE_HEADER_MAGIC = b"DataTransformEnvelope"
FOOTER_AEAD_MAGIC = b"DataTransformAeadFooter"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ classifiers = [
]
dependencies = [
"defusedxml",
"dissect.cstruct>=3.0.dev,<4.0.dev",
"dissect.util>=3.0.dev,<4.0.dev",
"dissect.cstruct>3,<5",
"dissect.util>2,<4",
]
dynamic = ["version"]

Expand Down
8 changes: 7 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ minversion = 4.4.3
requires = virtualenv>=20.16.6

[testenv]
extras = full
deps =
pytest
pytest-cov
coverage
# Unfortunately, tox does not allow separate installation flags for the project
# dependencies and the test dependencies. When running tox, we want to install the
# project dependencies with the --pre flag, so that we get the latest version of all
# dependencies. We do the installation step ourselves for this reason.
skip_install = true
commands_pre =
pip install --pre -e .[full]
commands =
pytest --basetemp="{envtmpdir}" {posargs:--color=yes --cov=dissect --cov-report=term-missing -v tests}
coverage report
Expand Down