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

Move helpers/network_manager.py to plugins/os/unix/linux/network_manager.py #869

Merged
merged 6 commits into from
Oct 4, 2024
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
8 changes: 4 additions & 4 deletions dissect/target/plugins/os/unix/linux/_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import logging

from dissect.target.filesystem import Filesystem
from dissect.target.helpers.network_managers import (
LinuxNetworkManager,
parse_unix_dhcp_log_messages,
)
from dissect.target.plugin import OperatingSystem, export
from dissect.target.plugins.os.unix._os import UnixPlugin
from dissect.target.plugins.os.unix.bsd.osx._os import MacPlugin
from dissect.target.plugins.os.unix.linux.network_managers import (
LinuxNetworkManager,
parse_unix_dhcp_log_messages,
)
from dissect.target.plugins.os.windows._os import WindowsPlugin
from dissect.target.target import Target

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@
from io import StringIO
from itertools import chain
from re import compile, sub
from typing import Any, Callable, Iterable, Iterator, Match, Optional
from typing import TYPE_CHECKING, Any, Callable, Iterable, Iterator, Match

from defusedxml import ElementTree

from dissect.target.exceptions import PluginError
from dissect.target.helpers.fsutil import TargetPath
from dissect.target.plugins.os.unix.log.journal import JournalRecord
from dissect.target.plugins.os.unix.log.messages import MessagesRecord
from dissect.target.target import Target

if TYPE_CHECKING:
from dissect.target.helpers.fsutil import TargetPath
from dissect.target.plugins.os.unix.log.journal import JournalRecord
from dissect.target.plugins.os.unix.log.messages import MessagesRecord
from dissect.target.target import Target

Check warning on line 20 in dissect/target/plugins/os/unix/linux/network_managers.py

View check run for this annotation

Codecov / codecov/patch

dissect/target/plugins/os/unix/linux/network_managers.py#L17-L20

Added lines #L17 - L20 were not covered by tests

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -57,7 +59,7 @@
"""Sets the name of the the used parsing template to the name of the discovered network manager."""
self.name = name

def create_config(self, path: TargetPath) -> Optional[dict]:
def create_config(self, path: TargetPath) -> dict | None:
"""Create a network config dictionary based on the configured template and supplied path.

Args:
Expand All @@ -81,7 +83,7 @@
config = self._parse_configparser_config(path)
return config

def _parse_netplan_config(self, path: TargetPath) -> Optional[dict]:
def _parse_netplan_config(self, path: TargetPath) -> dict | None:
"""Internal function to parse a netplan YAML based configuration file into a dict.

Args:
Expand Down Expand Up @@ -286,7 +288,7 @@
if option in translation_values and value:
return translation_key

def _get_option(self, config: dict, option: str, section: Optional[str] = None) -> Optional[str | Callable]:
def _get_option(self, config: dict, option: str, section: str | None = None) -> str | Callable | None:
"""Internal function to get arbitrary options values from a parsed (non-translated) dictionary.

Args:
Expand Down Expand Up @@ -334,7 +336,7 @@
self.config_globs = (config_globs,) if isinstance(config_globs, str) else config_globs
self.detection_globs = (detection_globs,) if isinstance(detection_globs, str) else detection_globs

def detect(self, target: Optional[Target] = None) -> bool:
def detect(self, target: Target | None = None) -> bool:
"""Detects if the network manager is active on the target

Returns:
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/os/unix/test_ips.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from dissect.target import Target
from dissect.target.filesystem import VirtualFilesystem
from dissect.target.helpers.network_managers import NetworkManager
from dissect.target.plugins.os.unix.linux._os import LinuxPlugin
from dissect.target.plugins.os.unix.linux.network_managers import NetworkManager
from dissect.target.tools.query import main as target_query
from tests._utils import absolute_path

Expand Down