Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with targetd integration #446

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions dissect/target/loaders/targetd.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,23 @@ def command_runner(link: str, targetd: Client, *args, **kwargs) -> None:
if namespace := kwargs.get("namespace", None):
obj = getattr(obj, namespace)

caller.has_output = True
if targetd.command == "init":
caller.has_output = True
caller.output = True
return

if targetd.command == "select":
targetd.rpcs.select(*args)
caller.output = True
return

if targetd.command == "deselect":
targetd.rpcs.deselect()
caller.output = True
return

func = getattr(obj, targetd.command)
caller.has_output = True

result = func(*args, **kwargs)
if result is not None:
if targetd.command == "get":
Expand Down
16 changes: 14 additions & 2 deletions dissect/target/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ def add_to_result(func: PluginFunction) -> None:

invalid_funcs = set()
show_hidden = kwargs.get("show_hidden", False)
ignore_load_errors = kwargs.get("ignore_load_errors", False)

for pattern in patterns.split(","):
# backward compatibility fix for namespace-level plugins (i.e. chrome)
Expand Down Expand Up @@ -1071,7 +1072,12 @@ def add_to_result(func: PluginFunction) -> None:
func = functions[index_name]

method_name = index_name.split(".")[-1]
loaded_plugin_object = load(func)
try:
loaded_plugin_object = load(func)
except Exception:
if ignore_load_errors:
continue
raise

# Skip plugins that don't want to be found by wildcards
if not show_hidden and not loaded_plugin_object.__findable__:
Expand Down Expand Up @@ -1120,7 +1126,13 @@ def add_to_result(func: PluginFunction) -> None:
invalid_funcs.add(pattern)

for description in plugin_descriptions:
loaded_plugin_object = load(description)
try:
loaded_plugin_object = load(description)
except Exception:
if ignore_load_errors:
continue
raise

fobject = inspect.getattr_static(loaded_plugin_object, funcname)

if compatibility and not loaded_plugin_object(target).is_compatible():
Expand Down