Add the comment about 'if arch' for the 'cut_attack_surface' checks
[kconfig-hardened-check.git] / kernel_hardening_checker / engine.py
index 7195bc01e8050e96a8c7218f048f368f5e9568ed..ee56d637b9b763e0dec0e9cfc41d38fcab3827cc 100644 (file)
@@ -9,15 +9,15 @@ This module is the engine of checks.
 """
 
 # pylint: disable=missing-class-docstring,missing-function-docstring
-# pylint: disable=line-too-long,invalid-name,too-many-branches
+# pylint: disable=line-too-long,too-many-branches
 
 from __future__ import annotations
 import sys
 
 from typing import Union, Optional, List, Dict, Tuple
 StrOrNone = Optional[str]
-TupleOrNone = Optional[Tuple]
-DictOrTuple = Union[Dict[str, str], Tuple]
+TupleOrNone = Optional[Tuple[int, ...]]
+DictOrTuple = Union[Dict[str, str], Tuple[int, ...]]
 StrOrBool = Union[str, bool]
 
 GREEN_COLOR = '\x1b[32m'
@@ -133,8 +133,8 @@ class OptCheck:
 
 
 class KconfigCheck(OptCheck):
-    def __init__(self, *args, **kwargs) -> None:
-        super().__init__(*args, **kwargs)
+    def __init__(self, *args: str) -> None:
+        super().__init__(*args)
         self.name = f'CONFIG_{self.name}'
 
     @property
@@ -161,16 +161,18 @@ class VersionCheck:
         assert(all(map(lambda x: isinstance(x, int), ver_expected))), \
                f'invalid expected version "{ver_expected}" for VersionCheck (2)'
         self.ver_expected = ver_expected
-        self.ver = (0, 0, 0) # type: Tuple[int, int, int]
+        self.ver = (0, 0, 0) # type: Tuple[int, ...]
         self.result = None # type: str | None
 
     @property
     def opt_type(self) -> str:
         return 'version'
 
-    def set_state(self, data: Tuple) -> None:
+    def set_state(self, data: Tuple[int, ...]) -> None:
         assert(data and isinstance(data, tuple) and len(data) >= 3), \
-               f'invalid version "{data}" for VersionCheck'
+               f'invalid version "{data}" for VersionCheck (1)'
+        assert(all(map(lambda x: isinstance(x, int), data))), \
+               f'invalid version "{data}" for VersionCheck (2)'
         self.ver = data[:3]
 
     def check(self) -> None: