dissect.target 3.20.dev56__py3-none-any.whl → 3.20.dev58__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  import datetime
2
+ import math
2
3
  import stat
3
4
  from typing import BinaryIO, Iterator, Optional, Union
4
5
 
@@ -100,16 +101,21 @@ class FatFilesystemEntry(FilesystemEntry):
100
101
  def lstat(self) -> fsutil.stat_result:
101
102
  """Return the stat information of the given path, without resolving links."""
102
103
  # mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime
103
- st_info = [
104
- (stat.S_IFDIR if self.is_dir() else stat.S_IFREG) | 0o777,
105
- self.entry.cluster,
106
- id(self.fs),
107
- 1,
108
- 0,
109
- 0,
110
- self.entry.size,
111
- self.entry.atime.replace(tzinfo=self.fs.tzinfo).timestamp(),
112
- self.entry.mtime.replace(tzinfo=self.fs.tzinfo).timestamp(),
113
- self.entry.ctime.replace(tzinfo=self.fs.tzinfo).timestamp(),
114
- ]
115
- return fsutil.stat_result(st_info)
104
+ st_info = fsutil.stat_result(
105
+ [
106
+ (stat.S_IFDIR if self.is_dir() else stat.S_IFREG) | 0o777,
107
+ self.entry.cluster,
108
+ id(self.fs),
109
+ 1,
110
+ 0,
111
+ 0,
112
+ self.entry.size,
113
+ self.entry.atime.replace(tzinfo=self.fs.tzinfo).timestamp(),
114
+ self.entry.mtime.replace(tzinfo=self.fs.tzinfo).timestamp(),
115
+ self.entry.ctime.replace(tzinfo=self.fs.tzinfo).timestamp(),
116
+ ]
117
+ )
118
+
119
+ st_info.st_blocks = math.ceil(self.entry.size / self.entry.fs.cluster_size)
120
+ st_info.st_blksize = self.entry.fs.cluster_size
121
+ return st_info
@@ -4,6 +4,7 @@ from typing import Iterator
4
4
 
5
5
  from defusedxml import ElementTree
6
6
  from dissect.util.ts import wintimestamp
7
+ from flow.record.base import is_valid_field_name
7
8
 
8
9
  from dissect.target.exceptions import UnsupportedPluginError
9
10
  from dissect.target.helpers.fsutil import Path
@@ -11,7 +12,9 @@ from dissect.target.helpers.record import DynamicDescriptor, TargetRecordDescrip
11
12
  from dissect.target.plugin import Plugin, export
12
13
  from dissect.target.target import Target
13
14
 
14
- camel_case_patterns = [re.compile(r"(\S)([A-Z][a-z]+)"), re.compile(r"([a-z0-9])([A-Z])"), re.compile(r"(\w)[.\s](\w)")]
15
+ CAMEL_CASE_PATTERNS = [re.compile(r"(\S)([A-Z][a-z]+)"), re.compile(r"([a-z0-9])([A-Z])"), re.compile(r"(\w)[.\s](\w)")]
16
+ RE_VALID_KEY_START_CHARS = re.compile(r"[a-zA-Z]")
17
+ RE_VALID_KEY_CHARS = re.compile(r"[a-zA-Z0-9_]")
15
18
 
16
19
 
17
20
  def _create_record_descriptor(record_name: str, record_fields: list[tuple[str, str]]) -> TargetRecordDescriptor:
@@ -49,13 +52,25 @@ class WindowsErrorReportingPlugin(Plugin):
49
52
 
50
53
  def _sanitize_key(self, key: str) -> str:
51
54
  # Convert camel case to snake case
52
- for pattern in camel_case_patterns:
55
+ for pattern in CAMEL_CASE_PATTERNS:
53
56
  key = pattern.sub(r"\1_\2", key)
54
57
 
55
- # Keep only basic characters in key
56
- key = re.sub(r"[^a-zA-Z0-9_]", "", key)
57
-
58
- return key.lower()
58
+ clean_key = ""
59
+ separator = "_"
60
+ prev_encoded = False
61
+ for idx, char in enumerate(key):
62
+ if prev_encoded:
63
+ clean_key += separator
64
+ clean_key += char
65
+ if not is_valid_field_name(clean_key):
66
+ clean_key = clean_key[:-1]
67
+ prefix = f"{separator}x" if (idx != 0 and not prev_encoded) else "x"
68
+ clean_key += prefix + char.encode("utf-8").hex()
69
+ prev_encoded = True
70
+ else:
71
+ prev_encoded = False
72
+
73
+ return clean_key.lower()
59
74
 
60
75
  def _collect_wer_data(self, wer_file: Path) -> tuple[list[tuple[str, str]], dict[str, str]]:
61
76
  """Parse data from a .wer file."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.20.dev56
3
+ Version: 3.20.dev58
4
4
  Summary: This module ties all other Dissect modules together, it provides a programming API and command line tools which allow easy access to various data sources inside disk images or file collections (a.k.a. targets)
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License: Affero General Public License v3
@@ -30,7 +30,7 @@ dissect/target/filesystems/cpio.py,sha256=ssVCjkAtLn2FqmNxeo6U5boyUdSYFxLWfXpytH
30
30
  dissect/target/filesystems/dir.py,sha256=rKEreX3A7CI6a3pMssrO9F-9i5pkxCn_Ucs_dMtHxxA,4574
31
31
  dissect/target/filesystems/exfat.py,sha256=PRkZPUVN5NlgB1VetFtywdNgF6Yj5OBtF5a25t-fFvw,5917
32
32
  dissect/target/filesystems/extfs.py,sha256=LVdB94lUI2DRHW0xUPx8lwuY-NKVeSwFGZiLOpZ8-Lk,4827
33
- dissect/target/filesystems/fat.py,sha256=cCIiUAY0-5dL76Zhvji1QbwlMVX7YqKWp-NmUdqz8yA,4605
33
+ dissect/target/filesystems/fat.py,sha256=bqpN4kVSz-0cz3P4QLk1ouJFw1xH1atCynW_ehXJAJE,4824
34
34
  dissect/target/filesystems/ffs.py,sha256=ry7aPb_AQeApTuhVQVioQPn4Q795_Ak5XloEtd-0bww,4950
35
35
  dissect/target/filesystems/itunes.py,sha256=w2lcWv6jlBPm84tsGZehxKBMXXyuW3KlmwVTF4ssQec,6395
36
36
  dissect/target/filesystems/jffs.py,sha256=fw25gM-Cx26VuTBmbaVNP1hKw73APkZ4RhI8MGY7-cQ,4207
@@ -300,7 +300,7 @@ dissect/target/plugins/os/windows/syscache.py,sha256=SXJxwyC34WPUpo0zGqbthdLPSPC
300
300
  dissect/target/plugins/os/windows/tasks.py,sha256=Bpy3tosncnFuGRqomEtB1jwJCVehZq4suhUznjtq4wo,5718
301
301
  dissect/target/plugins/os/windows/thumbcache.py,sha256=jAceapDdP9bNLGZchJ1l1okm7_7xiYHRbI2hVGAzMPk,4249
302
302
  dissect/target/plugins/os/windows/ual.py,sha256=S43ltndKKrs2SqeDLgZv4dzdqtJD8c3Y0Z8FK-Y9IOA,10076
303
- dissect/target/plugins/os/windows/wer.py,sha256=ogecvKYxAvDXLptQj4cn0JLn1FxaXjeSuJWs4JgkoZs,8656
303
+ dissect/target/plugins/os/windows/wer.py,sha256=y4ZU6Yai53UsZ4VLr0V9_uLhZJZ_UEtdPuNzxKbGoEY,9269
304
304
  dissect/target/plugins/os/windows/wua_history.py,sha256=QNtOQNZWKsKyUUrUV8aeoAMDKoH-ERkLx8ahnJzpHCY,54783
305
305
  dissect/target/plugins/os/windows/credential/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
306
306
  dissect/target/plugins/os/windows/credential/credhist.py,sha256=YSjuyd53Augdy_lKKzZHtx5Ozt0HzF6LDYIOb-8P1Pw,7058
@@ -378,10 +378,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
378
378
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
379
379
  dissect/target/volumes/md.py,sha256=7ShPtusuLGaIv27SvEETtgsuoQyAa4iAAeOR1NEaajI,1689
380
380
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
381
- dissect.target-3.20.dev56.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
382
- dissect.target-3.20.dev56.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
383
- dissect.target-3.20.dev56.dist-info/METADATA,sha256=BlpmEoddfX21zZoE-HnEubfrUSK46Ebc6kZsbYuK24o,13025
384
- dissect.target-3.20.dev56.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
385
- dissect.target-3.20.dev56.dist-info/entry_points.txt,sha256=BWuxAb_6AvUAQpIQOQU0IMTlaF6TDht2AIZK8bHd-zE,492
386
- dissect.target-3.20.dev56.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
387
- dissect.target-3.20.dev56.dist-info/RECORD,,
381
+ dissect.target-3.20.dev58.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
382
+ dissect.target-3.20.dev58.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
383
+ dissect.target-3.20.dev58.dist-info/METADATA,sha256=seB7oyVE8b59vkMXrmM129amhSswMf-hEzGiXR-qEyY,13025
384
+ dissect.target-3.20.dev58.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
385
+ dissect.target-3.20.dev58.dist-info/entry_points.txt,sha256=BWuxAb_6AvUAQpIQOQU0IMTlaF6TDht2AIZK8bHd-zE,492
386
+ dissect.target-3.20.dev58.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
387
+ dissect.target-3.20.dev58.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5