"""How the host is hardened: napalm-device-types' ``HardeningMixin`` (NetOrk/netork#2706). The command and its parse are napalm-device-types'; this is only how the command reaches the host. An exec channel, since ``aa-status --json`` prints one line longer than the PTY netmiko holds reliably takes. Read-only either way; root only for AppArmor's profiles, and the mixin falls back to the login user where it is refused. """ from __future__ import annotations from typing import TYPE_CHECKING from napalm_device_types import CommandResult, HardeningMixin #: Seconds the reading may take: a handful of small files and two quick tools. _READ_TIMEOUT = 60 class LinuxHardeningMixin(HardeningMixin): """The transport for ``get_hardening``.""" if TYPE_CHECKING: # pragma: no cover - the driver's own, declared for type checkers def run_command( self, command: str, *, privileged: bool = False, timeout: float = 60, stdin: bytes | None = None, ) -> CommandResult: ... def _run_hardening_command(self, command: str, *, privileged: bool) -> str: return self.run_command(command, privileged=privileged, timeout=_READ_TIMEOUT).stdout