dissect.hypervisor 3.22.dev3__py3-none-any.whl → 3.22.dev4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -22,9 +22,8 @@ class VisorTarInfo(tarfile.TarInfo):
22
22
  fixUpPgs: int | None
23
23
 
24
24
  @classmethod
25
- def frombuf(cls, buf: bytes, encoding: str, errors: str) -> VisorTarInfo:
26
- obj = super().frombuf(buf, encoding, errors)
27
-
25
+ def _init_visor_attrs(cls, obj: VisorTarInfo, buf: bytes) -> None:
26
+ """Initialize visor-specific attributes from the raw header buffer."""
28
27
  obj.is_visor = buf[257:264] == b"visor "
29
28
  if obj.is_visor:
30
29
  obj.offset_data = struct.unpack("<I", buf[496:500])[0]
@@ -35,6 +34,19 @@ class VisorTarInfo(tarfile.TarInfo):
35
34
  obj.textPgs = None
36
35
  obj.fixUpPgs = None
37
36
 
37
+ @classmethod
38
+ def frombuf(cls, buf: bytes, encoding: str, errors: str) -> VisorTarInfo:
39
+ obj = super().frombuf(buf, encoding, errors)
40
+ cls._init_visor_attrs(obj, buf)
41
+ return obj
42
+
43
+ @classmethod
44
+ def _frombuf(cls, buf: bytes, encoding: str, errors: str, **kwargs) -> VisorTarInfo:
45
+ # Python 3.13.13+ refactored tarfile to call _frombuf directly instead of
46
+ # frombuf in fromtarfile and _proc_gnulong/_proc_pax. We must override _frombuf
47
+ # to ensure visor-specific attributes are initialized for all code paths.
48
+ obj = super()._frombuf(buf, encoding, errors, **kwargs)
49
+ cls._init_visor_attrs(obj, buf)
38
50
  return obj
39
51
 
40
52
  def _proc_member(self, tarfile: tarfile.TarFile) -> VisorTarInfo | tarfile.TarInfo:
@@ -76,6 +88,8 @@ class VisorTarFile(tarfile.TarFile):
76
88
  try:
77
89
  t = cls.taropen(name, mode, fileobj, **kwargs)
78
90
  except Exception:
91
+ if fileobj is not None:
92
+ fileobj.seek(0)
79
93
  try:
80
94
  fileobj = GzipFile(name, mode + "b", fileobj=fileobj)
81
95
  except OSError as e:
@@ -103,10 +117,11 @@ class VisorTarFile(tarfile.TarFile):
103
117
  compressed = True
104
118
 
105
119
  # If we get here, we have a valid visor tar file
106
- if fileobj is not None and compressed:
107
- # Just read the entire file into memory, it's probably small
120
+ if fileobj is not None:
108
121
  fileobj.seek(0)
109
- fileobj = BytesIO(fileobj.read())
122
+ if compressed:
123
+ # Read the decompressed data into a BytesIO to make random reads faster
124
+ fileobj = BytesIO(fileobj.read())
110
125
 
111
126
  t = cls.taropen(name, mode, fileobj, **kwargs)
112
127
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.hypervisor
3
- Version: 3.22.dev3
3
+ Version: 3.22.dev4
4
4
  Summary: A Dissect module implementing parsers for various hypervisor disk, backup and configuration files
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -30,11 +30,11 @@ dissect/hypervisor/tools/envelope.py,sha256=BvaBSoXq3VrZ2GJVrfnL8NB6OLbdp8qD05je
30
30
  dissect/hypervisor/tools/vmtar.py,sha256=ArqAAUjSqktDmGCP6m-Bp1ujqWkDtCGC3xKz-WBa4m4,512
31
31
  dissect/hypervisor/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
32
  dissect/hypervisor/util/envelope.py,sha256=EhZjZh3EezqxkJ84OgqpptHIhpVWPcUkFMjdYU-iAnU,10442
33
- dissect/hypervisor/util/vmtar.py,sha256=xzc4bd5RnBgP9_dCU9i-ZwXI_0S3N7gCfMzElwwnd5s,4004
34
- dissect_hypervisor-3.22.dev3.dist-info/licenses/COPYRIGHT,sha256=EOOoIwk_inOMUD4c1ylpzMtYLjGzmc-MLEVAEdLLr20,305
35
- dissect_hypervisor-3.22.dev3.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
36
- dissect_hypervisor-3.22.dev3.dist-info/METADATA,sha256=vxysX3EN8XSQZHU7i47lA7JID71BH4abIn5zH5yZweg,3470
37
- dissect_hypervisor-3.22.dev3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
38
- dissect_hypervisor-3.22.dev3.dist-info/entry_points.txt,sha256=kW36GnJ3G1dSRYFL4r8Bj32Al_CkGqST3bdHvo3pyiY,120
39
- dissect_hypervisor-3.22.dev3.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
40
- dissect_hypervisor-3.22.dev3.dist-info/RECORD,,
33
+ dissect/hypervisor/util/vmtar.py,sha256=D728bup7WW5ZYFILQ6_jLQ2-fS7Qdr__Z6TJAABTUw0,4791
34
+ dissect_hypervisor-3.22.dev4.dist-info/licenses/COPYRIGHT,sha256=EOOoIwk_inOMUD4c1ylpzMtYLjGzmc-MLEVAEdLLr20,305
35
+ dissect_hypervisor-3.22.dev4.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
36
+ dissect_hypervisor-3.22.dev4.dist-info/METADATA,sha256=EiALPqcP_7F6zD3tqNAfg6ky2JSJkqrG6Qr-v-T_jks,3470
37
+ dissect_hypervisor-3.22.dev4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
38
+ dissect_hypervisor-3.22.dev4.dist-info/entry_points.txt,sha256=kW36GnJ3G1dSRYFL4r8Bj32Al_CkGqST3bdHvo3pyiY,120
39
+ dissect_hypervisor-3.22.dev4.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
40
+ dissect_hypervisor-3.22.dev4.dist-info/RECORD,,