dissect.target 3.19.dev8__py3-none-any.whl → 3.19.dev10__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -350,7 +350,7 @@ class FirefoxPlugin(BrowserPlugin):
350
350
 
351
351
  if not extension_file.exists():
352
352
  self.target.log.warning(
353
- "No 'extensions.json' addon file found for user %s in directory %s", user, profile_dir
353
+ "No 'extensions.json' addon file found for user %s in directory %s", user.user.name, profile_dir
354
354
  )
355
355
  continue
356
356
 
@@ -363,17 +363,17 @@ class FirefoxPlugin(BrowserPlugin):
363
363
  ts_update=extension.get("updateDate", 0) // 1000,
364
364
  browser="firefox",
365
365
  id=extension.get("id"),
366
- name=extension.get("defaultLocale", {}).get("name"),
366
+ name=(extension.get("defaultLocale", {}) or {}).get("name"),
367
367
  short_name=None,
368
368
  default_title=None,
369
- description=extension.get("defaultLocale", {}).get("description"),
369
+ description=(extension.get("defaultLocale", {}) or {}).get("description"),
370
370
  version=extension.get("version"),
371
371
  ext_path=extension.get("path"),
372
372
  from_webstore=None,
373
- permissions=extension.get("userPermissions", {}).get("permissions"),
373
+ permissions=(extension.get("userPermissions", {}) or {}).get("permissions"),
374
374
  manifest_version=extension.get("manifestVersion"),
375
375
  source_uri=extension.get("sourceURI"),
376
- optional_permissions=extension.get("optionalPermissions", {}).get("permissions"),
376
+ optional_permissions=(extension.get("optionalPermissions", {}) or {}).get("permissions"),
377
377
  source=extension_file,
378
378
  _target=self.target,
379
379
  _user=user.user,
@@ -381,7 +381,7 @@ class FirefoxPlugin(BrowserPlugin):
381
381
 
382
382
  except FileNotFoundError:
383
383
  self.target.log.info(
384
- "No 'extensions.json' addon file found for user %s in directory %s", user, profile_dir
384
+ "No 'extensions.json' addon file found for user %s in directory %s", user.user.name, profile_dir
385
385
  )
386
386
  except json.JSONDecodeError:
387
387
  self.target.log.warning(
@@ -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.dev8
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
@@ -124,7 +124,7 @@ dissect/target/plugins/apps/browser/browser.py,sha256=rBIwcgdl73gm-8APwx2jEUAYXR
124
124
  dissect/target/plugins/apps/browser/chrome.py,sha256=hxS8gqpBwoCrPaxNpllIa6K9DtsSGzn6XXcUaHyes6w,3048
125
125
  dissect/target/plugins/apps/browser/chromium.py,sha256=N9hS-a45iEv_GyKhLZQR_FSkEjWlMA0f22eURBuxF5Y,27999
126
126
  dissect/target/plugins/apps/browser/edge.py,sha256=woXzZtHPWmfcV8vbxGKHELKru5JRb32MAXs43_b4K4E,2883
127
- dissect/target/plugins/apps/browser/firefox.py,sha256=ROrzhI2SV81E63hi5PRtyJveRrBacWNJ9FWZS_ondlk,30929
127
+ dissect/target/plugins/apps/browser/firefox.py,sha256=3Ucp85DXTDyCofW1_aEzjba_Pr0QyC4F5gX8NqY-uOg,30981
128
128
  dissect/target/plugins/apps/browser/iexplore.py,sha256=g_xw0toaiyjevxO8g9XPCOqc-CXZp39FVquRhPFGdTE,8801
129
129
  dissect/target/plugins/apps/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
130
130
  dissect/target/plugins/apps/container/docker.py,sha256=KxQRbKGgxkf3YFBMa7fjeJ7qo8qjFys7zEmfQhDTnLw,15305
@@ -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.dev8.dist-info/COPYRIGHT,sha256=m-9ih2RVhMiXHI2bf_oNSSgHgkeIvaYRVfKTwFbnJPA,301
349
- dissect.target-3.19.dev8.dist-info/LICENSE,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
350
- dissect.target-3.19.dev8.dist-info/METADATA,sha256=zA-ZXpcU071N4CXn2gcBA5eRTWBrQHLRDqNW5MME_bY,12718
351
- dissect.target-3.19.dev8.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
352
- dissect.target-3.19.dev8.dist-info/entry_points.txt,sha256=tvFPa-Ap-gakjaPwRc6Fl6mxHzxEZ_arAVU-IUYeo_s,447
353
- dissect.target-3.19.dev8.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
354
- dissect.target-3.19.dev8.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,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (70.3.0)
2
+ Generator: setuptools (71.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5