feat(hardening): get_hardening through napalm-device-types' HardeningMixin (NetOrk/netork#2706)

The transport runs the shared, read-only command on an exec channel, as root
first for AppArmor's profiles and as the login user where root is refused.
This commit is contained in:
Christian Manivong committed 2026-11-26 23:12:59 +01:00
1 parent 670e62e0f0
commit a9ed615b9b
3 files changed
+64

No files matched your search

+8
View File
@@ -36,6 +36,7 @@ from napalm_device_types import (
ContainerEngineMixin,
EnsurePackageMixin,
FingerprintRule,
HardeningMixin,
HostFirewallMixin,
HostStatusMixin,
KernelFactsMixin,
@@ -277,6 +278,7 @@ class LinuxDriver(
EnsurePackageMixin,
AptProxyMixin,
KernelFactsMixin,
HardeningMixin,
ServicePackagesMixin,
LinuxProcessReadingsMixin,
HostFirewallMixin,
@@ -1051,6 +1053,12 @@ class LinuxDriver(
"""The transport for ``KernelFactsMixin.get_kernel_facts``: read-only, no sudo."""
return self._send(command, read_timeout=60)
def _run_hardening_command(self, command: str, *, privileged: bool) -> str:
"""The transport for ``HardeningMixin.get_hardening`` (NetOrk/netork#2706): 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."""
return self.run_command(command, privileged=privileged, timeout=60).stdout
def _run_service_packages_command(self, command: str) -> str:
"""The transport for ``ServicePackagesMixin.get_service_packages``.