dissect.apfs 1.1.dev2__py3-none-any.whl → 1.2.dev2__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.
dissect/apfs/__init__.py CHANGED
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  from dissect.apfs.apfs import APFS
2
4
  from dissect.apfs.exception import (
3
5
  Error,
dissect/apfs/c_apfs.py CHANGED
@@ -2,6 +2,8 @@
2
2
  # - https://developer.apple.com/support/downloads/Apple-File-System-Reference.pdf
3
3
  # - https://github.com/sgan81/apfs-fuse
4
4
  # - https://github.com/linux-apfs/linux-apfs-rw
5
+ from __future__ import annotations
6
+
5
7
  from dissect.cstruct import cstruct
6
8
 
7
9
  apfs_def = """
dissect/apfs/exception.py CHANGED
@@ -1,3 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+
1
4
  class Error(Exception):
2
5
  pass
3
6
 
@@ -792,27 +792,27 @@ class DirectoryEntry:
792
792
  @cached_property
793
793
  def type(self) -> int:
794
794
  """The file type of this directory entry."""
795
- return self.value.flags & c_apfs.DREC_TYPE_MASK << 12
795
+ return (self.value.flags & c_apfs.DREC_TYPE_MASK) << 12
796
796
 
797
797
  def is_dir(self) -> bool:
798
798
  """Return whether this directory entry is a directory."""
799
- return stat.S_ISDIR(self.type << 12)
799
+ return stat.S_ISDIR(self.type)
800
800
 
801
801
  def is_file(self) -> bool:
802
802
  """Return whether this directory entry is a regular file."""
803
- return stat.S_ISREG(self.type << 12)
803
+ return stat.S_ISREG(self.type)
804
804
 
805
805
  def is_symlink(self) -> bool:
806
806
  """Return whether this directory entry is a symbolic link."""
807
- return stat.S_ISLNK(self.type << 12)
807
+ return stat.S_ISLNK(self.type)
808
808
 
809
809
  def is_block_device(self) -> bool:
810
810
  """Return whether this directory entry is a block device."""
811
- return stat.S_ISBLK(self.type << 12)
811
+ return stat.S_ISBLK(self.type)
812
812
 
813
813
  def is_character_device(self) -> bool:
814
814
  """Return whether this directory entry is a character device."""
815
- return stat.S_ISCHR(self.type << 12)
815
+ return stat.S_ISCHR(self.type)
816
816
 
817
817
  def is_device(self) -> bool:
818
818
  """Return whether this directory entry is a device (block or character)."""
@@ -820,15 +820,15 @@ class DirectoryEntry:
820
820
 
821
821
  def is_fifo(self) -> bool:
822
822
  """Return whether this directory entry is a FIFO."""
823
- return stat.S_ISFIFO(self.type << 12)
823
+ return stat.S_ISFIFO(self.type)
824
824
 
825
825
  def is_socket(self) -> bool:
826
826
  """Return whether this directory entry is a socket."""
827
- return stat.S_ISSOCK(self.type << 12)
827
+ return stat.S_ISSOCK(self.type)
828
828
 
829
829
  def is_whiteout(self) -> bool:
830
830
  """Return whether this directory entry is a whiteout."""
831
- return stat.S_ISWHT(self.type << 12)
831
+ return stat.S_ISWHT(self.type)
832
832
 
833
833
 
834
834
  class XAttr:
@@ -292,7 +292,6 @@ def _create_cipher(key: bytes, iv: bytes = b"\x00" * 16, mode: str = "cbc") -> A
292
292
 
293
293
  Dynamic based on the available crypto module.
294
294
  """
295
-
296
295
  if HAS_PYSTANDALONE:
297
296
  key_size = len(key)
298
297
  if key_size not in (32, 24, 16):
dissect/apfs/stream.py CHANGED
@@ -88,26 +88,30 @@ class FileStream(AlignedStream):
88
88
 
89
89
  while length:
90
90
  logical_address, physical_address, extent_length, crypto_id = self._lookup(offset)
91
- block = self.volume.container._read_block(physical_address, extent_length // self.align)
91
+
92
+ offset_in_extent = offset - logical_address
93
+ if offset_in_extent >= extent_length:
94
+ raise Error(
95
+ f"Offset {offset:#x} is out of bounds for extent ({logical_address:#x}, {extent_length:#x})"
96
+ )
97
+
98
+ block_in_extent = offset_in_extent // self.align
99
+ read_length = min(extent_length - offset_in_extent, length)
100
+ block = self.volume.container._read_block(physical_address + block_in_extent, read_length // self.align)
92
101
 
93
102
  if self.volume.is_encrypted:
94
103
  if not self.volume._cipher:
95
104
  raise Error("Volume is encrypted, unlock it first")
96
105
 
97
106
  if self.volume.is_onekey:
98
- block = self.volume._cipher.decrypt(block, crypto_id * self.volume.container.sectors_per_block)
107
+ sector = (crypto_id + block_in_extent) * self.volume.container.sectors_per_block
108
+ block = self.volume._cipher.decrypt(block, sector)
99
109
  else:
100
110
  raise Error("Multi-key encryption is not supported yet")
101
111
 
102
- if offset_in_extent := offset - logical_address:
103
- block = block[offset_in_extent:]
104
-
105
- if length < len(block):
106
- block = block[:length]
107
-
108
112
  result.append(block)
109
- offset += min(extent_length, length)
110
- length -= min(extent_length, length)
113
+ offset += read_length
114
+ length -= read_length
111
115
 
112
116
  return b"".join(result)
113
117
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.apfs
3
- Version: 1.1.dev2
3
+ Version: 1.2.dev2
4
4
  Summary: A Dissect module implementing a parser for the APFS file system, a commonly used Apple file system
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -1,10 +1,10 @@
1
- dissect/apfs/__init__.py,sha256=4ihAtWM6Q-331fM4eSilok1s1seFNQoi3n2Gtu_o6h0,269
1
+ dissect/apfs/__init__.py,sha256=ilg-krPgae8UJxja1oKpQm4qt7-ntdTccLpQL6oZwi4,305
2
2
  dissect/apfs/apfs.py,sha256=zZzGDx1YT3SI6O0qsF6nyunpv0dmRdijQWSc7V--mAg,2575
3
- dissect/apfs/c_apfs.py,sha256=Rq-v9dkfDsx31pZPkPA79Y_ipVMThxPTEVHammG91gY,52189
3
+ dissect/apfs/c_apfs.py,sha256=fN_6UFNeFMKmneplj5-5OxXXCRtX6n-bD09ehklV62w,52225
4
4
  dissect/apfs/c_apfs.pyi,sha256=uC8exSo4ZPAG19UNDsBKaYe_Dzo1Vdmme4H2t1bfXd4,95421
5
5
  dissect/apfs/cursor.py,sha256=wN02FxEipcxUjw7roLcTa_wKjuxXofwNUnvrBrD04ac,5747
6
- dissect/apfs/exception.py,sha256=rVL-M01CBpk74d8VeeeqQuwD5P1WHluvNbAnj5D8BBw,263
7
- dissect/apfs/stream.py,sha256=DIjR1w8zsPt-_ye3x9nsUA2KshJjOsfsBlATcAJ_QTY,7550
6
+ dissect/apfs/exception.py,sha256=3Y0ZcM4ScZ3ajsUniWJUYQBay86dtz6-jt67uOzFUHI,300
7
+ dissect/apfs/stream.py,sha256=uR3QqZHy-owAoV0lARJ8e0W54DNXJAU0wRssrf_5gk8,7806
8
8
  dissect/apfs/util.py,sha256=a36KbuLbc7594V5_Iu8yggSSYF4057YSHd1z5nO0_ko,4688
9
9
  dissect/apfs/objects/__init__.py,sha256=d79CJGKxHrXOdLOhGp8cfvp_0A0Txi5KyFc6h9Fi7jw,1793
10
10
  dissect/apfs/objects/base.py,sha256=gr-8PGSzP7nPN7CkAdb1x2thuFK2wu-5S-Di9uD6XOs,6316
@@ -14,11 +14,11 @@ dissect/apfs/objects/checkpoint_map.py,sha256=sIrb8R5TYYFCW_8EsrjDrHGqYbUnetOnwD
14
14
  dissect/apfs/objects/efi_jumpstart.py,sha256=V9jb8f0ybckfRqTcezUqxacYWCqzYf-cc3GQ-93V6F8,313
15
15
  dissect/apfs/objects/er_recovery_block.py,sha256=qA2BoG4SE3F1MHCubzu_n39ModB-0cUKGTZukKoVGPs,367
16
16
  dissect/apfs/objects/er_state.py,sha256=zNU23weFk3WTrWIY_cWn0V8Ww_LXWaK9CE1BGHSnctY,323
17
- dissect/apfs/objects/fs.py,sha256=S_J0vr5d9_1_XetkvVCQjIh0duiNxiIslwwiK310SWI,31004
17
+ dissect/apfs/objects/fs.py,sha256=2x4wjPsHqvo6KITb6X9gSJFCgmIApwjw-lCouskbBKE,30958
18
18
  dissect/apfs/objects/gbitmap.py,sha256=RMVa9e1mxsarshc0kuNs9Hqwv5I8xff1X7RYHZkcYS8,295
19
19
  dissect/apfs/objects/gbitmap_block.py,sha256=erBYsQ4YPYCe_LwX8TSfHDf_UYlrGRmKFvl6P7CKuuk,324
20
20
  dissect/apfs/objects/integrity_meta.py,sha256=IFQe5E3II0TL4iP3RxjpLiCL7yaydu5Jp1G6h5EzWgo,322
21
- dissect/apfs/objects/keybag.py,sha256=icoMjei3xHEiiZGCoIqeF2rwzanw4B2qz6m4uWMtqVk,9258
21
+ dissect/apfs/objects/keybag.py,sha256=y9FB9CKe9T-WVigq7eRIyPSmaTkHiFdioTra2AiNpUE,9257
22
22
  dissect/apfs/objects/nx_fusion_wbc.py,sha256=HOrpiYbEaQY83o4q1M6XvwwAIljWMTtaLbE7RZi1kE4,320
23
23
  dissect/apfs/objects/nx_fusion_wbc_list.py,sha256=2RY6a2HzjAwoHAyp0MJVRNdbG8IEyBgl7SIGvBcMEug,344
24
24
  dissect/apfs/objects/nx_reap_list.py,sha256=P8Y9aPtTeXZWyuYmwBQVoZ-KCooAiSSr4gY_O0YQ15Y,311
@@ -30,9 +30,9 @@ dissect/apfs/objects/spaceman.py,sha256=LN8WHRA_QHhoQVdTid-5-CIXkYgcq3HOMwP5VaUE
30
30
  dissect/apfs/objects/spaceman_bitmap.py,sha256=F4idJVAmw2_6ypjH-Ovd-U-_ycBDvRdcQGTNByDDU1w,242
31
31
  dissect/apfs/objects/spaceman_cab.py,sha256=pf9tNPNoJTZ5Sae4n3UYci75XvYDJ-L0KrwfHDZ0qFQ,345
32
32
  dissect/apfs/objects/spaceman_cib.py,sha256=xKoIPb-Y4brgTZzpTw2Rqf564b0dAZZalcDtO6-326Y,334
33
- dissect_apfs-1.1.dev2.dist-info/licenses/COPYRIGHT,sha256=m2OYfg5NAsBXgWPGBn4p9g5-Fo0wViC65YkYsFNUaJk,299
34
- dissect_apfs-1.1.dev2.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
35
- dissect_apfs-1.1.dev2.dist-info/METADATA,sha256=0AwPmTcmD5rh_VyBgOJ-BfMhEnS4g6BNT-dGFFqsrHw,3361
36
- dissect_apfs-1.1.dev2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
37
- dissect_apfs-1.1.dev2.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
38
- dissect_apfs-1.1.dev2.dist-info/RECORD,,
33
+ dissect_apfs-1.2.dev2.dist-info/licenses/COPYRIGHT,sha256=m2OYfg5NAsBXgWPGBn4p9g5-Fo0wViC65YkYsFNUaJk,299
34
+ dissect_apfs-1.2.dev2.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
35
+ dissect_apfs-1.2.dev2.dist-info/METADATA,sha256=zyRIQCSsK-aAzJrHoc0EbjhTwzzxv3-TvQfWRQ3BTf4,3361
36
+ dissect_apfs-1.2.dev2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
37
+ dissect_apfs-1.2.dev2.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
38
+ dissect_apfs-1.2.dev2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (82.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5