Skip to content

Commit

Permalink
Allow Default/None-OS to access plugins (#346)
Browse files Browse the repository at this point in the history
(DIS-2138)
  • Loading branch information
cecinestpasunepipe authored Aug 7, 2023
1 parent a08ca70 commit 051a2b5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dissect/target/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,8 @@ def plugin_function_index(target: Target) -> tuple[dict[str, Any], set[str]]:

def all_plugins():
# Filter out plugins based on the target os
os_type = type(target._os) if target._os else None
os_type = type(target._os) if target._os and target._os.os != "default" else None

yield from plugins(os_type)
yield from os_plugins()
yield from child_plugins() # Doesn't export anything but added for completeness.
Expand Down
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def hive_hku():
yield hive


@pytest.fixture
def target_default():
mock_target = next(make_mock_target())
yield mock_target


@pytest.fixture
def target_win(hive_hklm, fs_win):
mock_target = next(make_mock_target())
Expand Down
14 changes: 12 additions & 2 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
get_external_module_paths,
save_plugin_import_failure,
)
from dissect.target.target import Target


def test_save_plugin_import_failure():
Expand Down Expand Up @@ -106,15 +107,24 @@ def f6(self):
assert len(found) == assert_num_found


def test_find_plugin_function_windows(target_win):
def test_find_plugin_function_windows(target_win: Target) -> None:
found, _ = find_plugin_functions(target_win, "services")

assert len(found) == 1
assert found[0].name == "os.windows.services.services"


def test_find_plugin_function_unix(target_unix):
def test_find_plugin_function_unix(target_unix: Target) -> None:
found, _ = find_plugin_functions(target_unix, "services")

assert len(found) == 1
assert found[0].name == "os.unix.services.services"


def test_find_plugin_function_default(target_default: Target) -> None:
found, _ = find_plugin_functions(target_default, "services")

assert len(found) == 2
names = [item.name for item in found]
assert "os.unix.services.services" in names
assert "os.windows.services.services" in names

0 comments on commit 051a2b5

Please sign in to comment.