feat: read what a Linux kernel has built and loaded, once for every driver
A kernel CVE's exploitability often hangs on code that is not there: a module neither loaded nor shipped, an option the kernel was built without. netOrk's KB precondition vocabulary asks exactly that (kernel_module, kernel_config). Reading it is the same on every Linux host, so the command and its parse live here and a driver supplies only the transport: - KERNEL_FACTS_COMMAND: one read-only POSIX sh line, no privileges. Release, /proc/modules, modules.builtin, modules.dep and the build configuration (/boot/config-* or /proc/config.gz). The report is framed, gzipped and base64-encoded, so nothing in it can look like a shell prompt to a screen-scraping transport, and ~300 kB of configuration crosses as a fifth. - parse_kernel_facts(): a section the command could not print comes back None, never empty -- "could not read" and "read, and nothing there" must stay apart. - module_name(): no path, no .ko suffix, "-" folded to "_", as the kernel does. - KernelFactsMixin, in the template form: get_kernel_facts() is concrete, _run_kernel_facts_command() is the driver's hook. Mixed in by the drivers that can, not by OSDriver -- a Windows host is an OS driver too, and hasattr(driver, "get_kernel_facts") has to stay truthful. - KernelFactsDict in models.py. Version 2.1.0.
This commit is contained in:
@@ -73,6 +73,12 @@ is a thin bundle over them — `PackageManagementMixin`, `HealthMetricsMixin`,
|
||||
`HostRebootMixin` (`reboot_host`) is mixed into `DeviceTypeDriver` itself, since any
|
||||
device may be restartable; like the others it only declares.
|
||||
|
||||
`KernelFactsMixin` (`get_kernel_facts`) is the exception that is mixed in by a driver
|
||||
rather than by a role base: what a Linux kernel has built and loaded is read the same way
|
||||
everywhere, so the command and its parse are concrete here and a driver supplies only
|
||||
`_run_kernel_facts_command`. `OSDriver` does not carry it — a Windows host is an OS driver
|
||||
too, and `hasattr(driver, "get_kernel_facts")` has to stay truthful.
|
||||
|
||||
A function class may use the **template form** — public method concrete, the
|
||||
device-specific part a `_hook` declared under `if TYPE_CHECKING` — *when the base
|
||||
genuinely does work* on the result: normalising, sorting, validating, or orchestrating
|
||||
|
||||
Reference in New Issue
Block a user