dissect.extfs 3.14.dev1__tar.gz → 3.15.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.
Files changed (31) hide show
  1. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/PKG-INFO +3 -4
  2. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect/extfs/extfs.py +34 -62
  3. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect.extfs.egg-info/PKG-INFO +3 -4
  4. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/pyproject.toml +25 -8
  5. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/conftest.py +1 -0
  6. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/test_ext4.py +1 -1
  7. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tox.ini +8 -10
  8. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/.git-blame-ignore-revs +0 -0
  9. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/.gitattributes +0 -0
  10. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/COPYRIGHT +0 -0
  11. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/LICENSE +0 -0
  12. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/MANIFEST.in +0 -0
  13. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/README.md +0 -0
  14. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect/extfs/__init__.py +0 -0
  15. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect/extfs/c_ext.py +0 -0
  16. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect/extfs/c_jdb2.py +0 -0
  17. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect/extfs/exceptions.py +0 -0
  18. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect/extfs/journal.py +0 -0
  19. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect.extfs.egg-info/SOURCES.txt +0 -0
  20. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect.extfs.egg-info/dependency_links.txt +0 -0
  21. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect.extfs.egg-info/requires.txt +0 -0
  22. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/dissect.extfs.egg-info/top_level.txt +0 -0
  23. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/setup.cfg +0 -0
  24. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/__init__.py +0 -0
  25. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/data/ext4.bin.gz +0 -0
  26. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/data/ext4_sparse.bin.gz +0 -0
  27. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/data/ext4_symlink_test.bin.gz +0 -0
  28. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/docs/Makefile +0 -0
  29. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/docs/conf.py +0 -0
  30. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/docs/index.rst +0 -0
  31. {dissect_extfs-3.14.dev1 → dissect_extfs-3.15.dev1}/tests/test_exceptions.py +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.extfs
3
- Version: 3.14.dev1
3
+ Version: 3.15.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
- License: Affero General Public License v3
6
+ License-Expression: AGPL-3.0-or-later
7
7
  Project-URL: homepage, https://dissect.tools
8
8
  Project-URL: documentation, https://docs.dissect.tools/en/latest/projects/dissect.extfs
9
9
  Project-URL: repository, https://github.com/fox-it/dissect.extfs
@@ -11,14 +11,13 @@ Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Environment :: Console
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: Intended Audience :: Information Technology
14
- Classifier: License :: OSI Approved
15
14
  Classifier: Operating System :: OS Independent
16
15
  Classifier: Programming Language :: Python :: 3
17
16
  Classifier: Topic :: Internet :: Log Analysis
18
17
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
19
18
  Classifier: Topic :: Security
20
19
  Classifier: Topic :: Utilities
21
- Requires-Python: ~=3.9
20
+ Requires-Python: >=3.10
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
23
  License-File: COPYRIGHT
@@ -4,7 +4,7 @@ import io
4
4
  import logging
5
5
  import os
6
6
  import stat
7
- from functools import lru_cache
7
+ from functools import cached_property, lru_cache
8
8
  from typing import TYPE_CHECKING, BinaryIO
9
9
  from uuid import UUID
10
10
 
@@ -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._journal = None
43
42
 
44
43
  fh.seek(c_ext.EXT2_SBOFF)
45
44
  sb = c_ext.ext4_super_block(fh)
@@ -99,22 +98,17 @@ class ExtFS:
99
98
  self.get_inode = lru_cache(1024)(self.get_inode)
100
99
  self._read_group_desc = lru_cache(356)(self._read_group_desc)
101
100
 
102
- @property
101
+ @cached_property
103
102
  def journal(self) -> JDB2:
104
- if not self._journal:
105
- if not self.sb.s_feature_compat & c_ext.EXT3_FEATURE_COMPAT_HAS_JOURNAL:
106
- raise Error("Journal not supported")
107
-
108
- inum = self.sb.s_journal_inum
109
- if inum == 0:
110
- raise Error(
111
- f"Journal inum is 0, could be on external device (s_journal_uuid = {self.sb.s_journal_uuid})"
112
- )
103
+ if not self.sb.s_feature_compat & c_ext.EXT3_FEATURE_COMPAT_HAS_JOURNAL:
104
+ raise Error("Journal not supported")
113
105
 
114
- inode = self.get_inode(inum)
115
- self._journal = JDB2(inode.open())
106
+ inum = self.sb.s_journal_inum
107
+ if inum == 0:
108
+ raise Error(f"Journal inum is 0, could be on external device (s_journal_uuid = {self.sb.s_journal_uuid})")
116
109
 
117
- return self._journal
110
+ inode = self.get_inode(inum)
111
+ return JDB2(inode.open())
118
112
 
119
113
  def get(self, path_or_inum: str | int, node: INode | None = None) -> INode:
120
114
  if isinstance(path_or_inum, int):
@@ -140,16 +134,11 @@ class ExtFS:
140
134
  inum: int,
141
135
  filename: str | None = None,
142
136
  filetype: int | None = None,
143
- lazy: bool = False,
144
137
  ) -> INode:
145
138
  if inum < c_ext.EXT2_BAD_INO or inum > self.sb.s_inodes_count:
146
139
  raise Error(f"inum out of range {c_ext.EXT2_BAD_INO}-{self.sb.s_inodes_count}: {inum}")
147
140
 
148
- inode = INode(self, inum, filename, filetype)
149
- if not lazy:
150
- inode._inode = inode._read_inode()
151
-
152
- return inode
141
+ return INode(self, inum, filename, filetype)
153
142
 
154
143
  def _read_group_desc(self, group_num: int) -> c_ext.ext2_group_desc | c_ext.ext4_group_desc:
155
144
  if group_num >= self.groups_count:
@@ -184,20 +173,15 @@ class INode:
184
173
  ):
185
174
  self.extfs = extfs
186
175
  self.inum = inum
187
- self._inode = None
188
-
189
176
  self.filename = filename
190
177
  self._filetype = filetype
191
- self._size = None
192
- self._link = None
193
- self._xattr = None
194
-
195
178
  self._runlist = None
196
179
 
197
180
  def __repr__(self) -> str:
198
181
  return f"<inode {self.inum}>"
199
182
 
200
- def _read_inode(self) -> c_ext.ext4_inode:
183
+ @cached_property
184
+ def inode(self) -> c_ext.ext4_inode:
201
185
  block_group_num, index = divmod(self.inum - 1, self.extfs.sb.s_inodes_per_group)
202
186
  block_group = self.extfs._read_group_desc(block_group_num)
203
187
 
@@ -210,17 +194,9 @@ class INode:
210
194
  self.extfs.fh.seek(offset)
211
195
  return c_ext.ext4_inode(self.extfs.fh)
212
196
 
213
- @property
214
- def inode(self) -> c_ext.ext4_inode:
215
- if not self._inode:
216
- self._inode = self._read_inode()
217
- return self._inode
218
-
219
- @property
197
+ @cached_property
220
198
  def size(self) -> int:
221
- if not self._size:
222
- self._size = (self.inode.i_size_high << 32) + self.inode.i_size_lo
223
- return self._size
199
+ return (self.inode.i_size_high << 32) + self.inode.i_size_lo
224
200
 
225
201
  @property
226
202
  def filetype(self) -> int:
@@ -228,41 +204,37 @@ class INode:
228
204
  self._filetype = stat.S_IFMT(self.inode.i_mode)
229
205
  return self._filetype
230
206
 
231
- @property
207
+ @cached_property
232
208
  def link(self) -> str:
233
209
  if self.filetype != stat.S_IFLNK:
234
210
  raise NotASymlinkError(f"{self!r} is not a symlink")
235
211
 
236
- if not self._link:
237
- self._link = self.open().read().decode(errors="surrogateescape")
238
- return self._link
212
+ return self.open().read().decode(errors="surrogateescape")
239
213
 
240
- @property
214
+ @cached_property
241
215
  def xattr(self) -> list[XAttr]:
242
- if not self._xattr:
243
- xattr = []
216
+ xattr = []
244
217
 
245
- if self.inode.i_extra.strip(b"\x00"):
246
- buf = io.BytesIO(self.inode.i_extra)
247
- hdr = c_ext.ext4_xattr_ibody_header(buf)
248
- if hdr.h_magic != c_ext.EXT4_XATTR_MAGIC:
249
- raise Error("Invalid xattr magic value")
218
+ if self.inode.i_extra.strip(b"\x00"):
219
+ buf = io.BytesIO(self.inode.i_extra)
220
+ hdr = c_ext.ext4_xattr_ibody_header(buf)
221
+ if hdr.h_magic != c_ext.EXT4_XATTR_MAGIC:
222
+ raise Error("Invalid xattr magic value")
250
223
 
251
- xattr.extend(_iter_xattr(self, buf, len(self.inode.i_extra), 4))
224
+ xattr.extend(_iter_xattr(self, buf, len(self.inode.i_extra), 4))
252
225
 
253
- if self.inode.i_file_acl_lo:
254
- block = (self.inode.i_file_acl_high << 32) | self.inode.i_file_acl_lo
255
- block_offset = block * self.extfs.block_size
226
+ if self.inode.i_file_acl_lo:
227
+ block = (self.inode.i_file_acl_high << 32) | self.inode.i_file_acl_lo
228
+ block_offset = block * self.extfs.block_size
256
229
 
257
- buf = RangeStream(self.extfs.fh, block_offset, self.extfs.block_size)
258
- hdr = c_ext.ext4_xattr_header(buf)
259
- if hdr.h_magic != c_ext.EXT4_XATTR_MAGIC:
260
- raise Error("Invalid xattr magic value")
230
+ buf = RangeStream(self.extfs.fh, block_offset, self.extfs.block_size)
231
+ hdr = c_ext.ext4_xattr_header(buf)
232
+ if hdr.h_magic != c_ext.EXT4_XATTR_MAGIC:
233
+ raise Error("Invalid xattr magic value")
261
234
 
262
- xattr.extend(_iter_xattr(self, buf, buf.size))
235
+ xattr.extend(_iter_xattr(self, buf, buf.size))
263
236
 
264
- self._xattr = xattr
265
- return self._xattr
237
+ return xattr
266
238
 
267
239
  @property
268
240
  def atime(self) -> datetime:
@@ -345,7 +317,7 @@ class INode:
345
317
  if ftype:
346
318
  ftype = FILETYPES[ftype]
347
319
 
348
- yield self.extfs.get_inode(direntry.inode, fname, ftype, lazy=True)
320
+ yield self.extfs.get_inode(direntry.inode, fname, ftype)
349
321
 
350
322
  offset += direntry.rec_len
351
323
  buf.seek(offset)
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.extfs
3
- Version: 3.14.dev1
3
+ Version: 3.15.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
- License: Affero General Public License v3
6
+ License-Expression: AGPL-3.0-or-later
7
7
  Project-URL: homepage, https://dissect.tools
8
8
  Project-URL: documentation, https://docs.dissect.tools/en/latest/projects/dissect.extfs
9
9
  Project-URL: repository, https://github.com/fox-it/dissect.extfs
@@ -11,14 +11,13 @@ Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Environment :: Console
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: Intended Audience :: Information Technology
14
- Classifier: License :: OSI Approved
15
14
  Classifier: Operating System :: OS Independent
16
15
  Classifier: Programming Language :: Python :: 3
17
16
  Classifier: Topic :: Internet :: Log Analysis
18
17
  Classifier: Topic :: Scientific/Engineering :: Information Analysis
19
18
  Classifier: Topic :: Security
20
19
  Classifier: Topic :: Utilities
21
- Requires-Python: ~=3.9
20
+ Requires-Python: >=3.10
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
23
  License-File: COPYRIGHT
@@ -1,13 +1,14 @@
1
1
  [build-system]
2
- requires = ["setuptools>=65.5.0", "setuptools_scm[toml]>=6.4.0"]
2
+ requires = ["setuptools>=77.0.0", "setuptools_scm[toml]>=6.4.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dissect.extfs"
7
7
  description = "A Dissect module implementing a parser for the ExtFS file system, the native filesystem for Linux operating systems"
8
8
  readme = "README.md"
9
- requires-python = "~=3.9"
10
- license.text = "Affero General Public License v3"
9
+ requires-python = ">=3.10"
10
+ license = "AGPL-3.0-or-later"
11
+ license-files = ["LICENSE", "COPYRIGHT"]
11
12
  authors = [
12
13
  {name = "Dissect Team", email = "dissect@fox-it.com"}
13
14
  ]
@@ -16,7 +17,6 @@ classifiers = [
16
17
  "Environment :: Console",
17
18
  "Intended Audience :: Developers",
18
19
  "Intended Audience :: Information Technology",
19
- "License :: OSI Approved",
20
20
  "Operating System :: OS Independent",
21
21
  "Programming Language :: Python :: 3",
22
22
  "Topic :: Internet :: Log Analysis",
@@ -41,9 +41,29 @@ dev = [
41
41
  "dissect.util>=3.0.dev,<4.0.dev",
42
42
  ]
43
43
 
44
+ [dependency-groups]
45
+ test = [
46
+ "pytest",
47
+ ]
48
+ lint = [
49
+ "ruff==0.13.1",
50
+ "vermin",
51
+ ]
52
+ build = [
53
+ "build",
54
+ ]
55
+ debug = [
56
+ "ipdb",
57
+ ]
58
+ dev = [
59
+ {include-group = "test"},
60
+ {include-group = "lint"},
61
+ {include-group = "debug"},
62
+ ]
63
+
44
64
  [tool.ruff]
45
65
  line-length = 120
46
- required-version = ">=0.9.0"
66
+ required-version = ">=0.13.1"
47
67
 
48
68
  [tool.ruff.format]
49
69
  docstring-code-format = true
@@ -92,9 +112,6 @@ ignore = ["E203", "B904", "UP024", "ANN002", "ANN003", "ANN204", "ANN401", "SIM1
92
112
  known-first-party = ["dissect.extfs"]
93
113
  known-third-party = ["dissect"]
94
114
 
95
- [tool.setuptools]
96
- license-files = ["LICENSE", "COPYRIGHT"]
97
-
98
115
  [tool.setuptools.packages.find]
99
116
  include = ["dissect.*"]
100
117
 
@@ -28,6 +28,7 @@ def ext4_bin() -> Iterator[BinaryIO]:
28
28
  def ext4_sparse_bin() -> Iterator[BinaryIO]:
29
29
  yield from gzip_file("data/ext4_sparse.bin.gz")
30
30
 
31
+
31
32
  @pytest.fixture
32
33
  def ext4_symlink_bin() -> Iterator[BinaryIO]:
33
34
  yield from gzip_file("data/ext4_symlink_test.bin.gz")
@@ -91,7 +91,7 @@ def test_infinite_loop_protection(ExtFS: ExtFS, log: Logger, *args) -> None:
91
91
  ExtFS.sb.s_inodes_count = 69
92
92
  ExtFS._dirtype = c_ext.ext2_dir_entry_2
93
93
  inode = INode(ExtFS, 1, filetype=stat.S_IFDIR)
94
- inode._size = 16
94
+ inode.size = 16
95
95
  for _ in inode.iterdir():
96
96
  pass
97
97
  assert call.critical("Zero-length directory entry in %s (offset 0x%x)", inode, 0) in log.mock_calls
@@ -4,7 +4,7 @@ envlist = lint, py3, pypy3
4
4
  # requires if they are not available on the host system. This requires the
5
5
  # locally installed tox to have a minimum version 3.3.0. This means the names
6
6
  # of the configuration options are still according to the tox 3.x syntax.
7
- minversion = 4.4.3
7
+ minversion = 4.27.0
8
8
  # This version of virtualenv will install setuptools version 68.2.2 and pip
9
9
  # 23.3.1. These versions fully support python projects defined only through a
10
10
  # pyproject.toml file (PEP-517/PEP-518/PEP-621). This pip version also support
@@ -14,9 +14,9 @@ requires = virtualenv>=20.24.6
14
14
  [testenv]
15
15
  extras = dev
16
16
  deps =
17
- pytest
18
17
  pytest-cov
19
18
  coverage
19
+ dependency_groups = test
20
20
  commands =
21
21
  pytest --basetemp="{envtmpdir}" {posargs:--color=yes --cov=dissect --cov-report=term-missing -v tests}
22
22
  coverage report
@@ -24,26 +24,24 @@ commands =
24
24
 
25
25
  [testenv:build]
26
26
  package = skip
27
- deps =
28
- build
27
+ dependency_groups = build
29
28
  commands =
30
29
  pyproject-build
31
30
 
32
31
  [testenv:fix]
33
32
  package = skip
34
- deps =
35
- ruff==0.9.2
33
+ dependency_groups = lint
36
34
  commands =
35
+ ruff check --fix dissect tests
37
36
  ruff format dissect tests
38
37
 
39
38
  [testenv:lint]
40
39
  package = skip
41
- deps =
42
- ruff==0.9.2
43
- vermin
40
+ dependency_groups = lint
44
41
  commands =
45
42
  ruff check dissect tests
46
- vermin -t=3.9- --no-tips --lint dissect tests
43
+ ruff format --check dissect tests
44
+ vermin -t=3.10- --no-tips --lint dissect tests
47
45
 
48
46
  [flake8]
49
47
  max-line-length = 120