dissect.evidence 3.14.dev3__py3-none-any.whl → 3.14.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.
- dissect/evidence/ad1/ad1.py +28 -8
- dissect/evidence/adcrypt/stream.py +3 -0
- {dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/METADATA +1 -1
- {dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/RECORD +9 -9
- {dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/WHEEL +1 -1
- {dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/entry_points.txt +0 -0
- {dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/licenses/COPYRIGHT +0 -0
- {dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/licenses/LICENSE +0 -0
- {dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/top_level.txt +0 -0
dissect/evidence/ad1/ad1.py
CHANGED
|
@@ -14,6 +14,9 @@ from dissect.evidence.exception import FileNotFoundError, NotADirectoryError, No
|
|
|
14
14
|
if TYPE_CHECKING:
|
|
15
15
|
from collections.abc import Iterator
|
|
16
16
|
from pathlib import PurePath
|
|
17
|
+
from types import TracebackType
|
|
18
|
+
|
|
19
|
+
from typing_extensions import Self
|
|
17
20
|
|
|
18
21
|
EntryType = c_ad1.EntryType
|
|
19
22
|
MetaType = c_ad1.MetaType
|
|
@@ -53,8 +56,9 @@ class AD1:
|
|
|
53
56
|
- https://al3ks1s.fr/posts/adventures-part-1/
|
|
54
57
|
"""
|
|
55
58
|
|
|
56
|
-
def __init__(self, fh: BinaryIO | list[BinaryIO]):
|
|
57
|
-
fhs = [fh] if not isinstance(fh, list) else fh
|
|
59
|
+
def __init__(self, fh: BinaryIO | list[BinaryIO] | Path | list[Path]):
|
|
60
|
+
fhs = find_files(fh) if isinstance(fh, Path) else [fh] if not isinstance(fh, list) else fh
|
|
61
|
+
|
|
58
62
|
self.fh = fhs
|
|
59
63
|
self.root = VirtualEntry(self, "/")
|
|
60
64
|
|
|
@@ -77,6 +81,14 @@ class AD1:
|
|
|
77
81
|
else:
|
|
78
82
|
self._open_ad1()
|
|
79
83
|
|
|
84
|
+
def __enter__(self) -> Self:
|
|
85
|
+
return self
|
|
86
|
+
|
|
87
|
+
def __exit__(
|
|
88
|
+
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
|
|
89
|
+
) -> None:
|
|
90
|
+
self.close()
|
|
91
|
+
|
|
80
92
|
def is_adcrypt(self) -> bool:
|
|
81
93
|
"""Return whether the AD1 container is ADCRYPT encrypted."""
|
|
82
94
|
return self.adcrypt is not None
|
|
@@ -91,7 +103,7 @@ class AD1:
|
|
|
91
103
|
Implements a simple LRU cache to limit the number of open segments.
|
|
92
104
|
|
|
93
105
|
Args:
|
|
94
|
-
idx: Index
|
|
106
|
+
idx: Index of the segment to open.
|
|
95
107
|
"""
|
|
96
108
|
# Poor mans LRU
|
|
97
109
|
if idx in self._segments:
|
|
@@ -103,21 +115,20 @@ class AD1:
|
|
|
103
115
|
oldest_idx = self._segment_lru.pop(0)
|
|
104
116
|
oldest_segment = self._segments.pop(oldest_idx)
|
|
105
117
|
|
|
106
|
-
#
|
|
107
|
-
if
|
|
118
|
+
# Only close file handles that we opened ourselves
|
|
119
|
+
if isinstance(self.fh[oldest_idx], Path):
|
|
108
120
|
oldest_segment.fh.close()
|
|
109
121
|
|
|
110
122
|
del oldest_segment
|
|
111
123
|
|
|
112
124
|
fh = self.fh[idx]
|
|
113
|
-
if
|
|
114
|
-
fh = fh.open("rb")
|
|
125
|
+
if isinstance(fh, Path):
|
|
126
|
+
fh = fh.open("rb")
|
|
115
127
|
|
|
116
128
|
if self.is_adcrypt() and not self.is_locked():
|
|
117
129
|
fh = self.adcrypt.wrap(fh, idx)
|
|
118
130
|
|
|
119
131
|
segment = SegmentFile(fh)
|
|
120
|
-
|
|
121
132
|
self._segments[idx] = segment
|
|
122
133
|
self._segment_lru.append(idx)
|
|
123
134
|
|
|
@@ -210,6 +221,15 @@ class AD1:
|
|
|
210
221
|
"""Shortcut for ``AD1.entry(path).open()``."""
|
|
211
222
|
return self.entry(path).open()
|
|
212
223
|
|
|
224
|
+
def close(self) -> None:
|
|
225
|
+
"""Close all segment file handles that we opened ourselves and clear the segment cache."""
|
|
226
|
+
for idx, segment in self._segments.items():
|
|
227
|
+
if isinstance(self.fh[idx], Path):
|
|
228
|
+
segment.fh.close()
|
|
229
|
+
|
|
230
|
+
self._segments = {}
|
|
231
|
+
self._segment_lru = []
|
|
232
|
+
|
|
213
233
|
|
|
214
234
|
def _hallicinate_root_entries(ad1: AD1) -> None:
|
|
215
235
|
# We need to create some fake entries for all parts leading up to `logical_image.name`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.evidence
|
|
3
|
-
Version: 3.14.
|
|
3
|
+
Version: 3.14.dev4
|
|
4
4
|
Summary: A Dissect module implementing a parsers for various forensic evidence file containers, currently: AD1, ASDF and EWF
|
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
|
6
6
|
License-Expression: AGPL-3.0-or-later
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
dissect/evidence/__init__.py,sha256=HBsn_m9aTzUqV0niqY6DV1GwKhtL2WfMf3i1LJFyxO4,257
|
|
2
2
|
dissect/evidence/exception.py,sha256=e--4r9hL1hWm0BeXaIqxsXcrjl60QAfYV3c2Q8caHss,570
|
|
3
3
|
dissect/evidence/ad1/__init__.py,sha256=p31RFzymZqk4dp2h8Ov9uAOk-lUqbT2rQujrfOFScTc,557
|
|
4
|
-
dissect/evidence/ad1/ad1.py,sha256=
|
|
4
|
+
dissect/evidence/ad1/ad1.py,sha256=xP9MVcgAPDb78Np9sojDrUDdLFBQ2nC90nGsFx47nJY,15598
|
|
5
5
|
dissect/evidence/ad1/c_ad1.py,sha256=3MWCTONFBj99M7ZZbzLMZM393uJqPqljMdvZZpeG78A,6421
|
|
6
6
|
dissect/evidence/ad1/c_ad1.pyi,sha256=m4m5VK1fRe4N5LNE-Cb1Datd1yutC6fptvKeq7fWH1k,7299
|
|
7
7
|
dissect/evidence/ad1/stream.py,sha256=clcugxOaTcgXS0C5M694pnmIRFgEI2Ip32iqkdBJ5hM,2539
|
|
@@ -9,7 +9,7 @@ dissect/evidence/adcrypt/__init__.py,sha256=6OZAzN5vI9EGAyDz4BNP2YO_Ev0dyCILDKNF
|
|
|
9
9
|
dissect/evidence/adcrypt/adcrypt.py,sha256=u_YABDws6Q92tMK6K7Lmx7BcLyPfSqmlXgONOzZ2Be0,5400
|
|
10
10
|
dissect/evidence/adcrypt/c_adcrypt.py,sha256=rE17LHpx1pSbsIxAupEwM8ZFY4U9BODAY8aCyRljZoM,1000
|
|
11
11
|
dissect/evidence/adcrypt/c_adcrypt.pyi,sha256=-m3voe_rrLWCScds9tl9CRzoVbGn7GqhN9O7yUICtGA,2195
|
|
12
|
-
dissect/evidence/adcrypt/stream.py,sha256=
|
|
12
|
+
dissect/evidence/adcrypt/stream.py,sha256=Zea3Jaj5WSqxmQV4CS41Wk6OOtMVIPy2shHCviakCa8,1198
|
|
13
13
|
dissect/evidence/asdf/__init__.py,sha256=Q7gUKk6Z5nR_DHnSo2ZfuUIlDNmARk420lC7A0GPwkg,213
|
|
14
14
|
dissect/evidence/asdf/asdf.py,sha256=5FvEQ0KsaCYvloNGbtqlQin1t52AvZFBpbgh8jbEkRY,22239
|
|
15
15
|
dissect/evidence/asdf/c_asdf.py,sha256=rfP2dVcJLxSbkNHZdDnCOM5Hs-ZKD_QY5e3iyxBQWQU,1803
|
|
@@ -28,10 +28,10 @@ dissect/evidence/tools/asdf/dd.py,sha256=GPsEqyGBefXkUCHxZUTHDi1j2Nw1w39h2Qr-RoG
|
|
|
28
28
|
dissect/evidence/tools/asdf/meta.py,sha256=bMb9pI49MgjeKhVXYPqhw74Cn0Sq-25YMzXU3cYaZro,2568
|
|
29
29
|
dissect/evidence/tools/asdf/repair.py,sha256=8iDzS7wmVfg35AKolMzOpbJVBx-CMPqOvxPAlBkKc9w,3071
|
|
30
30
|
dissect/evidence/tools/asdf/verify.py,sha256=zvxRvHNFZv6bicDE7RcT-jWgDKdYbLKMNTpGOwUJmfU,4161
|
|
31
|
-
dissect_evidence-3.14.
|
|
32
|
-
dissect_evidence-3.14.
|
|
33
|
-
dissect_evidence-3.14.
|
|
34
|
-
dissect_evidence-3.14.
|
|
35
|
-
dissect_evidence-3.14.
|
|
36
|
-
dissect_evidence-3.14.
|
|
37
|
-
dissect_evidence-3.14.
|
|
31
|
+
dissect_evidence-3.14.dev4.dist-info/licenses/COPYRIGHT,sha256=yExUrJwFMdmpUCxPrUiBR1pPQ_pGrr6hf3p231U6VnQ,303
|
|
32
|
+
dissect_evidence-3.14.dev4.dist-info/licenses/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
|
|
33
|
+
dissect_evidence-3.14.dev4.dist-info/METADATA,sha256=UbQPOFO8zJyy-CO1uyUEDPBt7IKtluq_ZEB-8WGa5J0,3340
|
|
34
|
+
dissect_evidence-3.14.dev4.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
35
|
+
dissect_evidence-3.14.dev4.dist-info/entry_points.txt,sha256=Wwci5PSqdS9koYEtx9lIsmPRfnKRJUG2UPAKpsJfGOI,268
|
|
36
|
+
dissect_evidence-3.14.dev4.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
|
|
37
|
+
dissect_evidence-3.14.dev4.dist-info/RECORD,,
|
{dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/licenses/COPYRIGHT
RENAMED
|
File without changes
|
{dissect_evidence-3.14.dev3.dist-info → dissect_evidence-3.14.dev4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|