dissect.target 3.19.dev9__py3-none-any.whl → 3.19.dev10__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.
@@ -16,7 +16,6 @@ import shutil
16
16
  import stat
17
17
  import subprocess
18
18
  import sys
19
- import traceback
20
19
  from contextlib import contextmanager
21
20
  from typing import Any, BinaryIO, Callable, Iterator, Optional, TextIO, Union
22
21
 
@@ -33,13 +32,15 @@ from dissect.target.exceptions import (
33
32
  )
34
33
  from dissect.target.filesystem import FilesystemEntry, LayerFilesystemEntry
35
34
  from dissect.target.helpers import cyber, fsutil, regutil
36
- from dissect.target.plugin import arg
35
+ from dissect.target.plugin import PluginFunction, arg
37
36
  from dissect.target.target import Target
38
37
  from dissect.target.tools.info import print_target_info
39
38
  from dissect.target.tools.utils import (
40
39
  args_to_uri,
41
40
  catch_sigpipe,
42
41
  configure_generic_arguments,
42
+ execute_function_on_target,
43
+ find_and_filter_plugins,
43
44
  generate_argparse_for_bound_method,
44
45
  process_generic_arguments,
45
46
  )
@@ -114,6 +115,7 @@ class TargetCmd(cmd.Cmd):
114
115
  cmd.Cmd.__init__(self)
115
116
  self.target = target
116
117
  self.debug = False
118
+ self.identchars += "."
117
119
 
118
120
  def __getattr__(self, attr: str) -> Any:
119
121
  if attr.startswith("help_"):
@@ -154,8 +156,8 @@ class TargetCmd(cmd.Cmd):
154
156
  except AttributeError:
155
157
  pass
156
158
 
157
- if self.target.has_function(command):
158
- return self._exec_target(command, command_args_str)
159
+ if plugins := list(find_and_filter_plugins(self.target, command, [])):
160
+ return self._exec_target(plugins, command_args_str)
159
161
 
160
162
  return cmd.Cmd.default(self, line)
161
163
 
@@ -213,24 +215,15 @@ class TargetCmd(cmd.Cmd):
213
215
  no_cyber = cmdfunc.__func__ in (TargetCli.cmd_registry, TargetCli.cmd_enter)
214
216
  return self._exec(_exec_, command_args_str, no_cyber)
215
217
 
216
- def _exec_target(self, func: str, command_args_str: str) -> Optional[bool]:
218
+ def _exec_target(self, funcs: list[PluginFunction], command_args_str: str) -> Optional[bool]:
217
219
  """Command exection helper for target plugins."""
218
- attr = self.target
219
- for part in func.split("."):
220
- attr = getattr(attr, part)
221
220
 
222
221
  def _exec_(argparts: list[str], stdout: TextIO) -> Optional[bool]:
223
- if callable(attr):
224
- argparser = generate_argparse_for_bound_method(attr)
225
- try:
226
- args = argparser.parse_args(argparts)
227
- except SystemExit:
228
- return False
229
- value = attr(**vars(args))
230
- else:
231
- value = attr
222
+ try:
223
+ output, value, _ = execute_function_on_target(self.target, func, argparts)
224
+ except SystemExit:
225
+ return False
232
226
 
233
- output = getattr(attr, "__output__", "default")
234
227
  if output == "record":
235
228
  # if the command results are piped to another process,
236
229
  # the process will receive Record objects
@@ -251,10 +244,16 @@ class TargetCmd(cmd.Cmd):
251
244
  else:
252
245
  print(value, file=stdout)
253
246
 
254
- try:
255
- return self._exec(_exec_, command_args_str)
256
- except PluginError:
257
- traceback.print_exc()
247
+ result = None
248
+ for func in funcs:
249
+ try:
250
+ result = self._exec(_exec_, command_args_str)
251
+ except PluginError as err:
252
+ if self.debug:
253
+ raise err
254
+ self.target.log.error(err)
255
+
256
+ return result
258
257
 
259
258
  def do_python(self, line: str) -> Optional[bool]:
260
259
  """drop into a Python shell"""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dissect.target
3
- Version: 3.19.dev9
3
+ Version: 3.19.dev10
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
@@ -331,7 +331,7 @@ dissect/target/tools/logging.py,sha256=5ZnumtMWLyslxfrUGZ4ntRyf3obOOhmn8SBjKfdLc
331
331
  dissect/target/tools/mount.py,sha256=L_0tSmiBdW4aSaF0vXjB0bAkTC0kmT2N1hrbW6s5Jow,3254
332
332
  dissect/target/tools/query.py,sha256=ONHu2FVomLccikb84qBrlhNmEfRoHYFQMcahk_y2c9A,15580
333
333
  dissect/target/tools/reg.py,sha256=FDsiBBDxjWVUBTRj8xn82vZe-J_d9piM-TKS3PHZCcM,3193
334
- dissect/target/tools/shell.py,sha256=1Z-gYRlJu0rmFI20taatlofrvp52ac_arXG8AMhwj0w,45182
334
+ dissect/target/tools/shell.py,sha256=_widEuIRqZhYzcFR52NYI8O2aPFm6tG5Uiv-AIrC32U,45155
335
335
  dissect/target/tools/utils.py,sha256=sQizexY3ui5vmWw4KOBLg5ecK3TPFjD-uxDqRn56ZTY,11304
336
336
  dissect/target/tools/dump/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
337
337
  dissect/target/tools/dump/run.py,sha256=aD84peRS4zHqC78fH7Vd4ni3m1ZmVP70LyMwBRvoDGY,9463
@@ -345,10 +345,10 @@ dissect/target/volumes/luks.py,sha256=OmCMsw6rCUXG1_plnLVLTpsvE1n_6WtoRUGQbpmu1z
345
345
  dissect/target/volumes/lvm.py,sha256=wwQVR9I3G9YzmY6UxFsH2Y4MXGBcKL9aayWGCDTiWMU,2269
346
346
  dissect/target/volumes/md.py,sha256=j1K1iKmspl0C_OJFc7-Q1BMWN2OCC5EVANIgVlJ_fIE,1673
347
347
  dissect/target/volumes/vmfs.py,sha256=-LoUbn9WNwTtLi_4K34uV_-wDw2W5hgaqxZNj4UmqAQ,1730
348
- dissect.target-3.19.dev9.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
349
- dissect.target-3.19.dev9.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
350
- dissect.target-3.19.dev9.dist-info/METADATA,sha256=KEe0VA16uLpcnxc2VQZNgkYTYZqRACn7KzWzU_sesx0,12718
351
- dissect.target-3.19.dev9.dist-info/WHEEL,sha256=FZ75kcLy9M91ncbIgG8dnpCncbiKXSRGJ_PFILs6SFg,91
352
- dissect.target-3.19.dev9.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
353
- dissect.target-3.19.dev9.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
354
- dissect.target-3.19.dev9.dist-info/RECORD,,
348
+ dissect.target-3.19.dev10.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
349
+ dissect.target-3.19.dev10.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
350
+ dissect.target-3.19.dev10.dist-info/METADATA,sha256=_IaES22tqwU15qttr5A5X3d0VUa43dSOESK8X8Ao0K0,12719
351
+ dissect.target-3.19.dev10.dist-info/WHEEL,sha256=FZ75kcLy9M91ncbIgG8dnpCncbiKXSRGJ_PFILs6SFg,91
352
+ dissect.target-3.19.dev10.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
353
+ dissect.target-3.19.dev10.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
354
+ dissect.target-3.19.dev10.dist-info/RECORD,,