X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=kernel_hardening_checker%2F__init__.py;h=a092e5c8cdbd432221291f879d62ffee3bd5a184;hb=7d8e8d5690ead4c66086ffde7676c5d9b3c1dabb;hp=212cf620dd78dd7722e17f2a0cc59f27d4f0cb8e;hpb=5a298be1e2af5e952cfd069e86c2de5c47bd4205;p=kconfig-hardened-check.git diff --git a/kernel_hardening_checker/__init__.py b/kernel_hardening_checker/__init__.py index 212cf62..a092e5c 100644 --- a/kernel_hardening_checker/__init__.py +++ b/kernel_hardening_checker/__init__.py @@ -150,7 +150,7 @@ def print_checklist(mode, checklist, with_results): print(f'[+] Config check is finished: \'OK\' - {ok_count}{ok_suppressed} / \'FAIL\' - {fail_count}{fail_suppressed}') -def parse_kconfig_file(mode, parsed_options, fname): +def parse_kconfig_file(_mode, parsed_options, fname): with _open(fname, 'rt', encoding='utf-8') as f: opt_is_on = re.compile(r"CONFIG_[a-zA-Z0-9_]+=.+$") opt_is_off = re.compile(r"# CONFIG_[a-zA-Z0-9_]+ is not set$") @@ -329,6 +329,10 @@ def main(): mmap_rnd_bits_max = parsed_kconfig_options.get('CONFIG_ARCH_MMAP_RND_BITS_MAX', None) if mmap_rnd_bits_max: override_expected_value(config_checklist, 'CONFIG_ARCH_MMAP_RND_BITS', mmap_rnd_bits_max) + else: + # remove the CONFIG_ARCH_MMAP_RND_BITS check to avoid false results + print('[-] Can\'t check CONFIG_ARCH_MMAP_RND_BITS without CONFIG_ARCH_MMAP_RND_BITS_MAX') + config_checklist[:] = [o for o in config_checklist if o.name != 'CONFIG_ARCH_MMAP_RND_BITS'] # now everything is ready, perform the checks perform_checks(config_checklist) @@ -401,6 +405,8 @@ def main(): for opt in config_checklist: if opt.name == 'CONFIG_ARCH_MMAP_RND_BITS': continue # don't add CONFIG_ARCH_MMAP_RND_BITS because its value needs refinement + if opt.expected == 'is not off': + continue # don't add Kconfig options without explicitly recommended values if opt.expected == 'is not set': print(f'# {opt.name} is not set') else: