dissect.extfs 3.13.dev2__tar.gz → 3.14.dev1__tar.gz
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_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/PKG-INFO +3 -2
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect/extfs/extfs.py +9 -29
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect.extfs.egg-info/PKG-INFO +3 -2
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect.extfs.egg-info/SOURCES.txt +1 -3
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/conftest.py +4 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/test_ext4.py +3 -20
- dissect_extfs-3.13.dev2/tests/data/ext4_symlink_test2.bin.gz +0 -0
- dissect_extfs-3.13.dev2/tests/data/ext4_symlink_test3.bin.gz +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/.git-blame-ignore-revs +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/.gitattributes +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/COPYRIGHT +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/LICENSE +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/MANIFEST.in +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/README.md +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect/extfs/__init__.py +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect/extfs/c_ext.py +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect/extfs/c_jdb2.py +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect/extfs/exceptions.py +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect/extfs/journal.py +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect.extfs.egg-info/dependency_links.txt +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect.extfs.egg-info/requires.txt +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect.extfs.egg-info/top_level.txt +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/pyproject.toml +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/setup.cfg +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/__init__.py +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/data/ext4.bin.gz +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/data/ext4_sparse.bin.gz +0 -0
- /dissect_extfs-3.13.dev2/tests/data/ext4_symlink_test1.bin.gz → /dissect_extfs-3.14.dev1/tests/data/ext4_symlink_test.bin.gz +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/docs/Makefile +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/docs/conf.py +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/docs/index.rst +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tests/test_exceptions.py +0 -0
- {dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/tox.ini +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.extfs
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.14.dev1
|
|
4
4
|
Summary: A Dissect module implementing a parser for the ExtFS file system, the native filesystem for Linux operating systems
|
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
|
6
6
|
License: Affero General Public License v3
|
|
@@ -27,6 +27,7 @@ Requires-Dist: dissect.util<4,>=3
|
|
|
27
27
|
Provides-Extra: dev
|
|
28
28
|
Requires-Dist: dissect.cstruct<5.0.dev,>=4.0.dev; extra == "dev"
|
|
29
29
|
Requires-Dist: dissect.util<4.0.dev,>=3.0.dev; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
# dissect.extfs
|
|
32
33
|
|
|
@@ -39,7 +39,6 @@ log.setLevel(os.getenv("DISSECT_LOG_EXTFS", "CRITICAL"))
|
|
|
39
39
|
class ExtFS:
|
|
40
40
|
def __init__(self, fh: BinaryIO):
|
|
41
41
|
self.fh = fh
|
|
42
|
-
# self._path_cache = {}
|
|
43
42
|
self._journal = None
|
|
44
43
|
|
|
45
44
|
fh.seek(c_ext.EXT2_SBOFF)
|
|
@@ -117,25 +116,22 @@ class ExtFS:
|
|
|
117
116
|
|
|
118
117
|
return self._journal
|
|
119
118
|
|
|
120
|
-
def get(self,
|
|
121
|
-
if isinstance(
|
|
122
|
-
return self.get_inode(
|
|
119
|
+
def get(self, path_or_inum: str | int, node: INode | None = None) -> INode:
|
|
120
|
+
if isinstance(path_or_inum, int):
|
|
121
|
+
return self.get_inode(path_or_inum)
|
|
123
122
|
|
|
124
123
|
node = node if node else self.root
|
|
125
|
-
parts =
|
|
126
|
-
for
|
|
124
|
+
parts = path_or_inum.split("/")
|
|
125
|
+
for part in parts:
|
|
127
126
|
if not part:
|
|
128
127
|
continue
|
|
129
128
|
|
|
130
|
-
while node.filetype == stat.S_IFLNK and part_num < len(parts):
|
|
131
|
-
node = node.link_inode
|
|
132
|
-
|
|
133
129
|
for entry in node.iterdir():
|
|
134
130
|
if entry.filename == part:
|
|
135
131
|
node = entry
|
|
136
132
|
break
|
|
137
133
|
else:
|
|
138
|
-
raise FileNotFoundError(f"File not found: {
|
|
134
|
+
raise FileNotFoundError(f"File not found: {path_or_inum}")
|
|
139
135
|
|
|
140
136
|
return node
|
|
141
137
|
|
|
@@ -144,13 +140,12 @@ class ExtFS:
|
|
|
144
140
|
inum: int,
|
|
145
141
|
filename: str | None = None,
|
|
146
142
|
filetype: int | None = None,
|
|
147
|
-
parent: INode | None = None,
|
|
148
143
|
lazy: bool = False,
|
|
149
144
|
) -> INode:
|
|
150
145
|
if inum < c_ext.EXT2_BAD_INO or inum > self.sb.s_inodes_count:
|
|
151
146
|
raise Error(f"inum out of range {c_ext.EXT2_BAD_INO}-{self.sb.s_inodes_count}: {inum}")
|
|
152
147
|
|
|
153
|
-
inode = INode(self, inum, filename, filetype
|
|
148
|
+
inode = INode(self, inum, filename, filetype)
|
|
154
149
|
if not lazy:
|
|
155
150
|
inode._inode = inode._read_inode()
|
|
156
151
|
|
|
@@ -186,21 +181,17 @@ class INode:
|
|
|
186
181
|
inum: int,
|
|
187
182
|
filename: str | None = None,
|
|
188
183
|
filetype: int | None = None,
|
|
189
|
-
parent: INode | None = None,
|
|
190
184
|
):
|
|
191
185
|
self.extfs = extfs
|
|
192
186
|
self.inum = inum
|
|
193
|
-
self.parent = parent
|
|
194
187
|
self._inode = None
|
|
195
188
|
|
|
196
189
|
self.filename = filename
|
|
197
190
|
self._filetype = filetype
|
|
198
191
|
self._size = None
|
|
199
192
|
self._link = None
|
|
200
|
-
self._link_inode = None
|
|
201
193
|
self._xattr = None
|
|
202
194
|
|
|
203
|
-
self._dirlist = None
|
|
204
195
|
self._runlist = None
|
|
205
196
|
|
|
206
197
|
def __repr__(self) -> str:
|
|
@@ -246,15 +237,6 @@ class INode:
|
|
|
246
237
|
self._link = self.open().read().decode(errors="surrogateescape")
|
|
247
238
|
return self._link
|
|
248
239
|
|
|
249
|
-
@property
|
|
250
|
-
def link_inode(self) -> INode:
|
|
251
|
-
if not self._link_inode:
|
|
252
|
-
# Relative lookups work because . and .. are actual directory entries
|
|
253
|
-
link = self.link
|
|
254
|
-
relnode = None if link.startswith("/") else self.parent
|
|
255
|
-
self._link_inode = self.extfs.get(self.link, relnode)
|
|
256
|
-
return self._link_inode
|
|
257
|
-
|
|
258
240
|
@property
|
|
259
241
|
def xattr(self) -> list[XAttr]:
|
|
260
242
|
if not self._xattr:
|
|
@@ -337,9 +319,7 @@ class INode:
|
|
|
337
319
|
return _parse_ns_ts(time, time_extra)
|
|
338
320
|
|
|
339
321
|
def listdir(self) -> dict[str, INode]:
|
|
340
|
-
|
|
341
|
-
self._dirlist = {node.filename: node for node in self.iterdir()}
|
|
342
|
-
return self._dirlist
|
|
322
|
+
return {node.filename: node for node in self.iterdir()}
|
|
343
323
|
|
|
344
324
|
dirlist = listdir
|
|
345
325
|
|
|
@@ -365,7 +345,7 @@ class INode:
|
|
|
365
345
|
if ftype:
|
|
366
346
|
ftype = FILETYPES[ftype]
|
|
367
347
|
|
|
368
|
-
yield self.extfs.get_inode(direntry.inode, fname, ftype,
|
|
348
|
+
yield self.extfs.get_inode(direntry.inode, fname, ftype, lazy=True)
|
|
369
349
|
|
|
370
350
|
offset += direntry.rec_len
|
|
371
351
|
buf.seek(offset)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: dissect.extfs
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.14.dev1
|
|
4
4
|
Summary: A Dissect module implementing a parser for the ExtFS file system, the native filesystem for Linux operating systems
|
|
5
5
|
Author-email: Dissect Team <dissect@fox-it.com>
|
|
6
6
|
License: Affero General Public License v3
|
|
@@ -27,6 +27,7 @@ Requires-Dist: dissect.util<4,>=3
|
|
|
27
27
|
Provides-Extra: dev
|
|
28
28
|
Requires-Dist: dissect.cstruct<5.0.dev,>=4.0.dev; extra == "dev"
|
|
29
29
|
Requires-Dist: dissect.util<4.0.dev,>=3.0.dev; extra == "dev"
|
|
30
|
+
Dynamic: license-file
|
|
30
31
|
|
|
31
32
|
# dissect.extfs
|
|
32
33
|
|
|
@@ -23,9 +23,7 @@ tests/test_exceptions.py
|
|
|
23
23
|
tests/test_ext4.py
|
|
24
24
|
tests/data/ext4.bin.gz
|
|
25
25
|
tests/data/ext4_sparse.bin.gz
|
|
26
|
-
tests/data/
|
|
27
|
-
tests/data/ext4_symlink_test2.bin.gz
|
|
28
|
-
tests/data/ext4_symlink_test3.bin.gz
|
|
26
|
+
tests/data/ext4_symlink_test.bin.gz
|
|
29
27
|
tests/docs/Makefile
|
|
30
28
|
tests/docs/conf.py
|
|
31
29
|
tests/docs/index.rst
|
|
@@ -27,3 +27,7 @@ def ext4_bin() -> Iterator[BinaryIO]:
|
|
|
27
27
|
@pytest.fixture
|
|
28
28
|
def ext4_sparse_bin() -> Iterator[BinaryIO]:
|
|
29
29
|
yield from gzip_file("data/ext4_sparse.bin.gz")
|
|
30
|
+
|
|
31
|
+
@pytest.fixture
|
|
32
|
+
def ext4_symlink_bin() -> Iterator[BinaryIO]:
|
|
33
|
+
yield from gzip_file("data/ext4_symlink_test.bin.gz")
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import datetime
|
|
4
|
-
import gzip
|
|
5
4
|
import stat
|
|
6
5
|
from io import BytesIO
|
|
7
6
|
from typing import TYPE_CHECKING, BinaryIO
|
|
8
7
|
from unittest.mock import call, patch
|
|
9
8
|
|
|
10
|
-
import pytest
|
|
11
|
-
|
|
12
9
|
from dissect.extfs.c_ext import c_ext
|
|
13
10
|
from dissect.extfs.extfs import EXT4, ExtFS, INode
|
|
14
11
|
|
|
@@ -80,25 +77,11 @@ def test_sparse(ext4_sparse_bin: BinaryIO) -> None:
|
|
|
80
77
|
assert sparse_all.dataruns() == [(None, 5120)]
|
|
81
78
|
|
|
82
79
|
|
|
83
|
-
|
|
84
|
-
"image_file",
|
|
85
|
-
[
|
|
86
|
-
("tests/data/ext4_symlink_test1.bin.gz"),
|
|
87
|
-
("tests/data/ext4_symlink_test2.bin.gz"),
|
|
88
|
-
("tests/data/ext4_symlink_test3.bin.gz"),
|
|
89
|
-
],
|
|
90
|
-
)
|
|
91
|
-
def test_symlinks(image_file: str) -> None:
|
|
80
|
+
def test_symlinks(ext4_symlink_bin: BinaryIO) -> None:
|
|
92
81
|
path = "/path/to/dir/with/file.ext"
|
|
93
|
-
expect = b"resolved!\n"
|
|
94
|
-
|
|
95
|
-
def resolve(node: INode) -> INode:
|
|
96
|
-
while node.filetype == stat.S_IFLNK:
|
|
97
|
-
node = node.link_inode
|
|
98
|
-
return node
|
|
99
82
|
|
|
100
|
-
|
|
101
|
-
|
|
83
|
+
extfs = ExtFS(ext4_symlink_bin)
|
|
84
|
+
assert extfs.get(path).link == "../../../../other/path/source/to/my/file.ext"
|
|
102
85
|
|
|
103
86
|
|
|
104
87
|
@patch("dissect.extfs.extfs.INode.open", return_value=BytesIO(b"\x00" * 16))
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{dissect_extfs-3.13.dev2 → dissect_extfs-3.14.dev1}/dissect.extfs.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|