From: Alexander Popov Date: Sun, 12 May 2024 16:20:33 +0000 (+0300) Subject: Add more typing annotations to checks.py X-Git-Tag: v0.6.10~67^2~16 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=36bfc8b21e6c84f59e4182bb359b34e8904202d0;p=kconfig-hardened-check.git Add more typing annotations to checks.py Annotate all functions to enable mypy checking for them. --- diff --git a/kernel_hardening_checker/checks.py b/kernel_hardening_checker/checks.py index 193b374..ab2432e 100644 --- a/kernel_hardening_checker/checks.py +++ b/kernel_hardening_checker/checks.py @@ -11,10 +11,11 @@ This module contains knowledge for checks. # pylint: disable=missing-function-docstring,line-too-long,invalid-name # pylint: disable=too-many-branches,too-many-statements,too-many-locals -from .engine import KconfigCheck, CmdlineCheck, SysctlCheck, VersionCheck, OR, AND +from .engine import StrOrNone, KconfigCheck, CmdlineCheck, SysctlCheck, VersionCheck, OR, AND +from typing import List -def add_kconfig_checks(l, arch: str): +def add_kconfig_checks(l: List, arch: str) -> None: assert(arch), 'empty arch' # Calling the KconfigCheck class constructor: @@ -422,7 +423,7 @@ def add_kconfig_checks(l, arch: str): l += [KconfigCheck('harden_userspace', 'a13xp0p0v', 'X86_USER_SHADOW_STACK', 'y')] -def add_cmdline_checks(l, arch: str): +def add_cmdline_checks(l: List, arch: str) -> None: assert(arch), 'empty arch' # Calling the CmdlineCheck class constructor: @@ -657,7 +658,7 @@ def normalize_cmdline_options(option: str, value: str) -> str: # kernel.warn_limit (think about a proper value) # net.ipv4.tcp_syncookies=1 (?) -def add_sysctl_checks(l, _arch: str): +def add_sysctl_checks(l: List, _arch: StrOrNone) -> None: # This function may be called with arch=None # Calling the SysctlCheck class constructor: