Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions dissect/hypervisor/disk/c_asif.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Generated by cstruct-stubgen
from typing import BinaryIO, Literal, overload
from typing import BinaryIO, Literal, TypeAlias, overload

import dissect.cstruct as __cs__
from typing_extensions import TypeAlias

class _c_asif(__cs__.cstruct):
ASIF_HEADER_SIGNATURE: Literal[1936221303] = ...
Expand Down
3 changes: 1 addition & 2 deletions dissect/hypervisor/disk/c_qcow2.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Generated by cstruct-stubgen
from typing import BinaryIO, Literal, overload
from typing import BinaryIO, Literal, TypeAlias, overload

import dissect.cstruct as __cs__
from typing_extensions import TypeAlias

class _c_qcow2(__cs__.cstruct):
MIN_CLUSTER_BITS: Literal[9] = ...
Expand Down
4 changes: 2 additions & 2 deletions dissect/hypervisor/disk/vhdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
from functools import lru_cache
from pathlib import Path
from typing import TYPE_CHECKING, Any, BinaryIO, Callable, Final
from typing import TYPE_CHECKING, Any, BinaryIO, Final
from uuid import UUID

from dissect.util.stream import AlignedStream
Expand All @@ -29,7 +29,7 @@
from dissect.hypervisor.exceptions import InvalidSignature, InvalidVirtualDisk

if TYPE_CHECKING:
from collections.abc import Iterator
from collections.abc import Callable, Iterator

log = logging.getLogger(__name__)
log.setLevel(os.getenv("DISSECT_LOG_VHDX", "CRITICAL"))
Expand Down
4 changes: 2 additions & 2 deletions dissect/hypervisor/util/vmtar.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def visoropen(cls, name: str, mode: str = "r", fileobj: BinaryIO | None = None,
raise tarfile.TarError("visor currently only supports read mode")

try:
from gzip import GzipFile
from gzip import GzipFile # noqa: PLC0415
except ImportError:
raise tarfile.CompressionError("gzip module is not available") from None

try:
from lzma import LZMAError, LZMAFile
from lzma import LZMAError, LZMAFile # noqa: PLC0415
except ImportError:
raise tarfile.CompressionError("lzma module is not available") from None

Expand Down
33 changes: 25 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[build-system]
requires = ["setuptools>=65.5.0", "setuptools_scm[toml]>=6.4.0"]
requires = ["setuptools>=77.0.0", "setuptools_scm[toml]>=6.4.0"]
build-backend = "setuptools.build_meta"

[project]
name = "dissect.hypervisor"
description = "A Dissect module implementing parsers for various hypervisor disk, backup and configuration files"
readme = "README.md"
requires-python = "~=3.9"
license.text = "Affero General Public License v3"
requires-python = ">=3.10"
license = "AGPL-3.0-or-later"
license-files = ["LICENSE", "COPYRIGHT"]
authors = [
{name = "Dissect Team", email = "dissect@fox-it.com"}
]
Expand All @@ -16,7 +17,6 @@ classifiers = [
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"License :: OSI Approved",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Topic :: Internet :: Log Analysis",
Expand Down Expand Up @@ -46,13 +46,33 @@ dev = [
"dissect.util>=3.0.dev,<4.0.dev",
]

[dependency-groups]
test = [
"pytest",
]
lint = [
"ruff==0.13.1",
"vermin",
]
build = [
"build",
]
debug = [
"ipdb",
]
dev = [
{include-group = "test"},
{include-group = "lint"},
{include-group = "debug"},
]

[project.scripts]
envelope-decrypt = "dissect.hypervisor.tools.envelope:main"
vmtar = "dissect.hypervisor.tools.vmtar:main"

[tool.ruff]
line-length = 120
required-version = ">=0.11.0"
required-version = ">=0.13.1"

[tool.ruff.format]
docstring-code-format = true
Expand Down Expand Up @@ -102,9 +122,6 @@ ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM1
known-first-party = ["dissect.hypervisor"]
known-third-party = ["dissect"]

[tool.setuptools]
license-files = ["LICENSE", "COPYRIGHT"]

[tool.setuptools.packages.find]
include = ["dissect.*"]

Expand Down
2 changes: 1 addition & 1 deletion tests/disk/test_hdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_split_hdd(split_hdd: Path) -> None:

start = 0

for storage, split_size in zip(storages, split_sizes):
for storage, split_size in zip(storages, split_sizes, strict=False):
assert storage.start == start
assert storage.end == start + split_size
assert len(storage.images) == 1
Expand Down
10 changes: 5 additions & 5 deletions tests/disk/test_qcow2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_basic(basic_qcow2: BinaryIO) -> None:
def test_data_file(data_file_qcow2: Path) -> None:
# Test with file handle
with gzip.open(data_file_qcow2, "rb") as fh:
with pytest.raises(Error, match="data-file required but not provided \\(image_data_file = 'data-file.bin'\\)"):
with pytest.raises(Error, match=r"data-file required but not provided \(image_data_file = 'data-file.bin'\)"):
QCow2(fh)

with gzip.open(data_file_qcow2.with_name("data-file.bin.gz"), "rb") as fh_bin:
Expand All @@ -47,7 +47,7 @@ def test_data_file(data_file_qcow2: Path) -> None:
# Test with allow_no_data_file
qcow2 = QCow2(fh, allow_no_data_file=True)
assert qcow2.data_file is None
with pytest.raises(Error, match="data-file required but not provided \\(image_data_file = 'data-file.bin'\\)"):
with pytest.raises(Error, match=r"data-file required but not provided \(image_data_file = 'data-file.bin'\)"):
qcow2.open()

# Test with Path
Expand All @@ -68,12 +68,12 @@ def test_backing_file(backing_chain_qcow2: tuple[Path, Path, Path]) -> None:
# Test with file handle
with gzip.open(file1, "rb") as fh1, gzip.open(file2, "rb") as fh2, gzip.open(file3, "rb") as fh3:
with pytest.raises(
Error, match="backing-file required but not provided \\(auto_backing_file = 'backing-chain-2.qcow2'\\)"
Error, match=r"backing-file required but not provided \(auto_backing_file = 'backing-chain-2.qcow2'\)"
):
QCow2(fh1)

with pytest.raises(
Error, match="backing-file required but not provided \\(auto_backing_file = 'backing-chain-3.qcow2'\\)"
Error, match=r"backing-file required but not provided \(auto_backing_file = 'backing-chain-3.qcow2'\)"
):
QCow2(fh1, backing_file=fh2)

Expand All @@ -87,7 +87,7 @@ def test_backing_file(backing_chain_qcow2: tuple[Path, Path, Path]) -> None:
qcow2 = QCow2(fh1, allow_no_backing_file=True)
assert qcow2.backing_file is None
with pytest.raises(
Error, match="backing-file required but not provided \\(auto_backing_file = 'backing-chain-2.qcow2'\\)"
Error, match=r"backing-file required but not provided \(auto_backing_file = 'backing-chain-2.qcow2'\)"
):
qcow2.open()

Expand Down
20 changes: 8 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist = lint, py3, pypy3
# requires if they are not available on the host system. This requires the
# locally installed tox to have a minimum version 3.3.0. This means the names
# of the configuration options are still according to the tox 3.x syntax.
minversion = 4.4.3
minversion = 4.27.0
# This version of virtualenv will install setuptools version 68.2.2 and pip
# 23.3.1. These versions fully support python projects defined only through a
# pyproject.toml file (PEP-517/PEP-518/PEP-621). This pip version also support
Expand All @@ -14,38 +14,34 @@ requires = virtualenv>=20.24.6
[testenv]
extras = dev
deps =
pytest
pytest-cov
coverage
dependency_groups = test
commands =
pytest --basetemp="{envtmpdir}" {posargs:--color=yes --cov=dissect --cov-report=term-missing -v tests}
coverage report
coverage xml

[testenv:build]
package = skip
deps =
build
dependency_groups = build
commands =
pyproject-build

[testenv:fix]
package = skip
deps =
ruff==0.11.10
dependency_groups = lint
commands =
ruff format dissect tests
ruff check --fix dissect tests
ruff format dissect tests

[testenv:lint]
package = skip
deps =
ruff==0.11.10
vermin
dependency_groups = lint
commands =
ruff format --check dissect tests
ruff check dissect tests
vermin -t=3.9- --no-tips --lint dissect tests
ruff format --check dissect tests
vermin -t=3.10- --no-tips --lint dissect tests

[testenv:docs-build]
allowlist_externals = make
Expand Down
Loading