Skip the kernel version part after '-'
authorAlexander Popov <alex.popov@linux.com>
Sat, 9 Mar 2024 17:24:07 +0000 (20:24 +0300)
committerAlexander Popov <alex.popov@linux.com>
Sat, 9 Mar 2024 17:24:07 +0000 (20:24 +0300)
Example:
# Linux/x86_64 6.7.4-200.fc39.x86_64 Kernel Configuration

Refers to #88, #89, #97

kernel_hardening_checker/__init__.py

index 2fa789d4fbd2c1883e9b1b46157a21041ada74b7..4855a59445bca6e120e8347aa0a1dba1994e1705 100644 (file)
@@ -53,7 +53,7 @@ def detect_kernel_version(fname):
             if ver_pattern.match(line):
                 line = line.strip()
                 parts = line.split()
-                ver_str = parts[2]
+                ver_str = parts[2].split('-', 1)[0]
                 ver_numbers = ver_str.split('.')
                 if len(ver_numbers) < 3 or not ver_numbers[0].isdigit() or not ver_numbers[1].isdigit():
                     msg = f'failed to parse the version "{ver_str}"'