From: Alexander Popov Date: Sat, 9 Mar 2024 20:46:51 +0000 (+0300) Subject: Check all 3 numbers of the kernel version in VersionCheck X-Git-Tag: v0.6.10~99 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=bd8c4c03599c07ad8cbf6d7677c8e8954ca27523;p=kconfig-hardened-check.git Check all 3 numbers of the kernel version in VersionCheck Refers to #88, #89, #97 --- diff --git a/kernel_hardening_checker/engine.py b/kernel_hardening_checker/engine.py index 960f4f4..844e9f0 100644 --- a/kernel_hardening_checker/engine.py +++ b/kernel_hardening_checker/engine.py @@ -151,18 +151,26 @@ class VersionCheck: def check(self): if self.ver[0] > self.ver_expected[0]: - self.result = f'OK: version >= {self.ver_expected[0]}.{self.ver_expected[1]}' + self.result = f'OK: version >= {self.ver_expected}' return if self.ver[0] < self.ver_expected[0]: - self.result = f'FAIL: version < {self.ver_expected[0]}.{self.ver_expected[1]}' + self.result = f'FAIL: version < {self.ver_expected}' return - if self.ver[1] >= self.ver_expected[1]: - self.result = f'OK: version >= {self.ver_expected[0]}.{self.ver_expected[1]}' + # self.ver[0] and self.ver_expected[0] are equal + if self.ver[1] > self.ver_expected[1]: + self.result = f'OK: version >= {self.ver_expected}' return - self.result = f'FAIL: version < {self.ver_expected[0]}.{self.ver_expected[1]}' + if self.ver[1] < self.ver_expected[1]: + self.result = f'FAIL: version < {self.ver_expected}' + return + # self.ver[1] and self.ver_expected[1] are equal too + if self.ver[2] >= self.ver_expected[2]: + self.result = f'OK: version >= {self.ver_expected}' + return + self.result = f'FAIL: version < {self.ver_expected}' def table_print(self, _mode, with_results): - ver_req = f'kernel version >= {self.ver_expected[0]}.{self.ver_expected[1]}' + ver_req = f'kernel version >= {self.ver_expected}' print(f'{ver_req:<91}', end='') if with_results: print(f'| {colorize_result(self.result)}', end='')