diff --git a/dissect/target/containers/asif.py b/dissect/target/containers/asif.py new file mode 100644 index 0000000000..64e38911d6 --- /dev/null +++ b/dissect/target/containers/asif.py @@ -0,0 +1,46 @@ +from __future__ import annotations + +import io +from typing import TYPE_CHECKING, BinaryIO + +from dissect.hypervisor.disk import asif + +from dissect.target.container import Container + +if TYPE_CHECKING: + from pathlib import Path + + +class AsifContainer(Container): + __type__ = "asif" + + def __init__( + self, + fh: BinaryIO | Path, + *args, + **kwargs, + ): + self.asif = asif.ASIF(fh.open("rb") if not hasattr(fh, "read") else fh) + self.stream = self.asif.open() + + super().__init__(fh, self.asif.size, *args, **kwargs) + + @staticmethod + def _detect_fh(fh: BinaryIO, original: list | BinaryIO) -> bool: + return fh.read(4) == b"shdw" + + @staticmethod + def detect_path(path: Path, original: list | BinaryIO) -> bool: + return path.suffix.lower() == ".asif" + + def read(self, length: int) -> bytes: + return self.stream.read(length) + + def seek(self, offset: int, whence: int = io.SEEK_SET) -> int: + return self.stream.seek(offset, whence) + + def tell(self) -> int: + return self.stream.tell() + + def close(self) -> None: + self.stream.close() diff --git a/pyproject.toml b/pyproject.toml index 769b3ca576..d562f65a63 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ "dissect.cstruct>=4,<5", "dissect.eventlog>=3,<4", "dissect.evidence>=3,<4", - "dissect.hypervisor>=3.19,<4", + "dissect.hypervisor>=3.20.dev,<4", # TODO: update on release "dissect.ntfs>=3.15.dev1,<4", # TODO: update on release "dissect.regf>=3.13,<4", "dissect.sql>=3.12,<4", @@ -89,7 +89,7 @@ dev = [ "dissect.fat[dev]>=3.0.dev,<4.0.dev", "dissect.ffs[dev]>=3.0.dev,<4.0.dev", "dissect.fve[dev]>=4.2.dev,<5.0.dev; platform_system != 'Windows' or platform_python_implementation != 'PyPy'", - "dissect.hypervisor[dev]>=3.19.dev,<4.0.dev", + "dissect.hypervisor[dev]>=3.20.dev,<4.0.dev", "dissect.jffs[dev]>=1.5.dev,<2.0.dev", "dissect.ntfs[dev]>=3.15.dev,<4.0.dev", "dissect.qnxfs[dev]>=1.1.dev,<2.0.dev",