feat(hardening): where the OS runs and whose CPU it is, and installing the CPU microcode, 4.53.0 (NetOrk/netork#2838)
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 1m11s
driver / test (3.12) (pull_request) Successful in 1m12s
driver / test (3.13) (pull_request) Successful in 1m5s
driver / lowest (pull_request) Successful in 34s
driver / build (pull_request) Successful in 27s
driver / types (pull_request) Successful in 1m50s
driver / security (pull_request) Successful in 58s
CI / driver (pull_request) Successful in 2m12s
driver / publish (pull_request) Skipped
driver / standard (pull_request) Successful in 16s
driver / lint (pull_request) Successful in 1m11s
driver / test (3.12) (pull_request) Successful in 1m12s
driver / test (3.13) (pull_request) Successful in 1m5s
driver / lowest (pull_request) Successful in 34s
driver / build (pull_request) Successful in 27s
driver / types (pull_request) Successful in 1m50s
driver / security (pull_request) Successful in 58s
CI / driver (pull_request) Successful in 2m12s
driver / publish (pull_request) Skipped
get_hardening() reads virtualization (systemd-detect-virt, else the cpuinfo hypervisor flag) and cpu_vendor. CpuMicrocodeMixin.install_cpu_microcode() refuses a guest, picks the package of the distribution and CPU vendor (microcode_package), adds Debian's firmware component to Debian's own sources where it is missing, reloads the index and installs the package; it loads at the next boot.
This commit is contained in:
1 parent
5faf9a1021
commit
7451fc9dfc
8 files changed
+913
-3
No files matched your search
@@ -43,6 +43,9 @@ ALMA_9 = [
|
||||
"BHI: Not affected\n"
|
||||
"/sys/devices/system/cpu/vulnerabilities/mmio_stale_data:Unknown: No mitigations",
|
||||
),
|
||||
("virtualization", "kvm"),
|
||||
("cpu_hypervisor", "1"),
|
||||
("cpu_vendor", "vendor_id\t: AuthenticAMD"),
|
||||
]
|
||||
|
||||
AA_STATUS = {
|
||||
@@ -124,6 +127,8 @@ class TestTheFixtures:
|
||||
"mitigations": "auto",
|
||||
"nosmt": False,
|
||||
"os_ids": ["almalinux", "rhel", "centos", "fedora"],
|
||||
"virtualization": "kvm",
|
||||
"cpu_vendor": "AuthenticAMD",
|
||||
}
|
||||
|
||||
def test_ubuntu_24_04_apparmor_with_its_profiles(self):
|
||||
@@ -170,6 +175,8 @@ class TestNotReadIsNone:
|
||||
"mitigations": None,
|
||||
"nosmt": None,
|
||||
"os_ids": None,
|
||||
"virtualization": None,
|
||||
"cpu_vendor": None,
|
||||
}
|
||||
|
||||
def test_an_empty_vulnerabilities_directory_is_read_and_empty(self):
|
||||
@@ -303,6 +310,43 @@ class TestCommandLine:
|
||||
assert (reading["mitigations"], reading["nosmt"]) == (mitigations, nosmt)
|
||||
|
||||
|
||||
class TestVirtualization:
|
||||
"""Whether the host runs on its own hardware: ``systemd-detect-virt`` where it is
|
||||
installed, else the ``hypervisor`` CPU flag a hypervisor sets for its guests."""
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"sections, virtualization",
|
||||
[
|
||||
([("virtualization", "none"), ("cpu_hypervisor", "0")], "none"),
|
||||
([("virtualization", "kvm"), ("cpu_hypervisor", "1")], "kvm"),
|
||||
([("virtualization", "lxc"), ("cpu_hypervisor", "0")], "lxc"),
|
||||
([("virtualization", "VMware")], "vmware"),
|
||||
([("cpu_hypervisor", "1")], "vm"),
|
||||
([("cpu_hypervisor", "0")], "none"),
|
||||
([("virtualization", ""), ("cpu_hypervisor", "1")], "vm"),
|
||||
([("cpu_hypervisor", "nonsense")], None),
|
||||
([], None),
|
||||
],
|
||||
)
|
||||
def test_detect_virt_first_then_the_cpu_flag(self, sections, virtualization):
|
||||
assert parse_hardening(_wire(sections))["virtualization"] == virtualization
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"line, vendor",
|
||||
[
|
||||
("vendor_id\t: GenuineIntel", "GenuineIntel"),
|
||||
("vendor_id : AuthenticAMD", "AuthenticAMD"),
|
||||
("vendor_id\t:", None),
|
||||
],
|
||||
)
|
||||
def test_the_cpu_vendor(self, line, vendor):
|
||||
assert parse_hardening(_wire([("cpu_vendor", line)]))["cpu_vendor"] == vendor
|
||||
|
||||
def test_no_vendor_line_is_unread(self):
|
||||
"""An ARM CPU's ``/proc/cpuinfo`` has no ``vendor_id``."""
|
||||
assert parse_hardening(_wire([("cpu_vendor", "")]))["cpu_vendor"] is None
|
||||
|
||||
|
||||
class TestCryptoPolicy:
|
||||
def test_a_subpolicy_is_kept(self):
|
||||
reading = parse_hardening(_wire([("crypto_policy", "LEGACY:AD-SUPPORT"), ("fips", "1")]))
|
||||
@@ -389,3 +433,4 @@ class TestTheCommand:
|
||||
|
||||
assert reading["cmdline"] is not None
|
||||
assert reading["mitigations"] is not None
|
||||
assert reading["virtualization"] is not None
|
||||
Reference in new issue
Block a user