dissect.target 3.18.dev11__py3-none-any.whl → 3.18.dev13__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,77 @@
1
+ import fnmatch
2
+ import logging
3
+ import re
4
+ from pathlib import Path
5
+ from typing import Iterator
6
+
7
+ from dissect.target import Target
8
+ from dissect.target.helpers.record import TargetRecordDescriptor
9
+ from dissect.target.plugin import arg, export
10
+ from dissect.target.plugins.general.config import (
11
+ ConfigurationEntry,
12
+ ConfigurationTreePlugin,
13
+ )
14
+
15
+ UnixConfigTreeRecord = TargetRecordDescriptor(
16
+ "unix/config",
17
+ [
18
+ ("path", "source"),
19
+ ("path", "path"),
20
+ ("string", "key"),
21
+ ("string[]", "value"),
22
+ ],
23
+ )
24
+
25
+ log = logging.getLogger(__name__)
26
+
27
+
28
+ class EtcTree(ConfigurationTreePlugin):
29
+ __namespace__ = "etc"
30
+
31
+ def __init__(self, target: Target):
32
+ super().__init__(target, "/etc")
33
+
34
+ def _sub(self, items: ConfigurationEntry, entry: Path, pattern: str) -> Iterator[UnixConfigTreeRecord]:
35
+ index = 0
36
+ config_entry = items
37
+ if not isinstance(items, dict):
38
+ items = items.as_dict()
39
+
40
+ for raw_key, value in items.items():
41
+ key = re.sub(r"[\n\r\t]", "", raw_key)
42
+ path = Path(entry) / Path(key)
43
+
44
+ if isinstance(value, dict):
45
+ yield from self._sub(value, path, pattern)
46
+ continue
47
+
48
+ if not isinstance(value, list):
49
+ value = [str(value)]
50
+
51
+ if fnmatch.fnmatch(path, pattern):
52
+ data = {
53
+ "_target": self.target,
54
+ "source": self.target.fs.path(config_entry.entry.path),
55
+ "path": path,
56
+ "key": key,
57
+ "value": value,
58
+ }
59
+ if value == [""]:
60
+ data["key"] = index
61
+ data["value"] = [key]
62
+ index += 1
63
+
64
+ yield UnixConfigTreeRecord(**data)
65
+
66
+ @export(record=UnixConfigTreeRecord)
67
+ @arg("--glob", dest="pattern", required=False, default="*", type=str, help="Glob-style pattern to search for")
68
+ def etc(self, pattern: str) -> Iterator[UnixConfigTreeRecord]:
69
+ for entry, subs, items in self.config_fs.walk("/"):
70
+ for item in items:
71
+ try:
72
+ config_object = self.get(str(Path(entry) / Path(item)))
73
+ if isinstance(config_object, ConfigurationEntry):
74
+ yield from self._sub(config_object, Path(entry) / Path(item), pattern)
75
+ except Exception:
76
+ log.warning("Could not open configuration item: %s", item)
77
+ pass
@@ -52,7 +52,7 @@ class CommandHistoryPlugin(Plugin):
52
52
  for user_details in self.target.user_details.all_with_home():
53
53
  for shell, history_relative_path in self.COMMAND_HISTORY_RELATIVE_PATHS:
54
54
  history_path = user_details.home_path.joinpath(history_relative_path)
55
- if history_path.exists():
55
+ if history_path.is_file():
56
56
  history_files.append((shell, history_path, user_details.user))
57
57
  return history_files
58
58
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.18.dev11
3
+ Version: 3.18.dev13
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
@@ -189,7 +189,7 @@ dissect/target/plugins/os/unix/cronjobs.py,sha256=2ssj97UVJueyATVl7NMJmqd9uHflQ2
189
189
  dissect/target/plugins/os/unix/datetime.py,sha256=gKfBdPyUirt3qmVYfOJ1oZXRPn8wRzssbZxR_ARrtk8,1518
190
190
  dissect/target/plugins/os/unix/etc.py,sha256=HoPEC1hxqurSnAXQAK-jf_HxdBIDe-1z_qSw_n-ViI4,258
191
191
  dissect/target/plugins/os/unix/generic.py,sha256=6_MJrV1LbIxNQJwAZR0HEQljoxwF5BPQC1SfCTcaSHg,2127
192
- dissect/target/plugins/os/unix/history.py,sha256=1o6ZLQTDimo9FSm9h_8QpCWlg8_qTb8ewDMgDqdAeV8,6619
192
+ dissect/target/plugins/os/unix/history.py,sha256=ptNGHkHOLJ5bE4r1PqtkQFcQHqzS6-qe5ms1tTGOJp8,6620
193
193
  dissect/target/plugins/os/unix/locale.py,sha256=V3R7mEyrH3f-h7SGAucByaYYDA2SIil9Qb-s3dPmDEA,3961
194
194
  dissect/target/plugins/os/unix/packagemanager.py,sha256=Wm2AAJOD_B3FAcZNXgWtSm_YwbvrHBYOP8bPmOXNjG4,2427
195
195
  dissect/target/plugins/os/unix/shadow.py,sha256=TvN04uzFnUttNMZAa6_1XdXSP-8V6ztbZNoetDvfD0w,3535
@@ -209,6 +209,8 @@ dissect/target/plugins/os/unix/bsd/osx/_os.py,sha256=KvP7YJ7apVwoIop7MR-8q5QbVGo
209
209
  dissect/target/plugins/os/unix/bsd/osx/user.py,sha256=qopB0s3n7e6Q7NjWzn8Z-dKtDtU7e6In4Vm7hIvvedo,2322
210
210
  dissect/target/plugins/os/unix/esxi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
211
211
  dissect/target/plugins/os/unix/esxi/_os.py,sha256=8kFFK9986zN8hXmDUWwdQHtbV33nWKerRuisg_xbsoQ,17504
212
+ dissect/target/plugins/os/unix/etc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
213
+ dissect/target/plugins/os/unix/etc/etc.py,sha256=ZyuMfP1QKA2_l8XQVu5CLex049MVFre3Yru5otiAqpE,2531
212
214
  dissect/target/plugins/os/unix/linux/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
213
215
  dissect/target/plugins/os/unix/linux/_os.py,sha256=YJYwuq_iAinOrPqTE49Q4DLYMWBeRCly1uTbDvPhp6Q,2796
214
216
  dissect/target/plugins/os/unix/linux/cmdline.py,sha256=AyMfndt3UsmJtoOyZYC8nWq2GZg9oPvn8SiI3M4NxnE,1622
@@ -343,10 +345,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
343
345
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
344
346
  dissect/target/volumes/md.py,sha256=j1K1iKmspl0C_OJFc7-Q1BMWN2OCC5EVANIgVlJ_fIE,1673
345
347
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
346
- dissect.target-3.18.dev11.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
347
- dissect.target-3.18.dev11.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
348
- dissect.target-3.18.dev11.dist-info/METADATA,sha256=mWlhvOaO7RcVbyJ0_fU7KHrnNaVL2vQ6a7uKhPvJ-kM,12723
349
- dissect.target-3.18.dev11.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
350
- dissect.target-3.18.dev11.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
351
- dissect.target-3.18.dev11.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
352
- dissect.target-3.18.dev11.dist-info/RECORD,,
348
+ dissect.target-3.18.dev13.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
349
+ dissect.target-3.18.dev13.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
350
+ dissect.target-3.18.dev13.dist-info/METADATA,sha256=OthWeUBoWP8O_B_gllOH4d-q-RLIsnOc0JdjeUct5B0,12723
351
+ dissect.target-3.18.dev13.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
352
+ dissect.target-3.18.dev13.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
353
+ dissect.target-3.18.dev13.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
354
+ dissect.target-3.18.dev13.dist-info/RECORD,,