From: Alexander Popov Date: Fri, 24 Mar 2023 20:17:39 +0000 (+0300) Subject: Prevent populating the checklist with empty data X-Git-Tag: v0.6.6~199 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=d8aa12692026607864113b25b6f19501412d3d94;p=kconfig-hardened-check.git Prevent populating the checklist with empty data --- diff --git a/kconfig_hardened_check/engine.py b/kconfig_hardened_check/engine.py index 6308740..8a4ccb8 100644 --- a/kconfig_hardened_check/engine.py +++ b/kconfig_hardened_check/engine.py @@ -254,6 +254,8 @@ def populate_simple_opt_with_data(opt, data, data_type): f'invalid opt type "{opt.type}"' assert(data_type in SIMPLE_OPTION_TYPES), \ f'invalid data type "{data_type}"' + assert(data), \ + f'empty data' if data_type != opt.type: return diff --git a/kconfig_hardened_check/test_engine.py b/kconfig_hardened_check/test_engine.py index baabd96..710e99a 100644 --- a/kconfig_hardened_check/test_engine.py +++ b/kconfig_hardened_check/test_engine.py @@ -53,9 +53,12 @@ class TestEngine(unittest.TestCase): parsed_kconfig_options, parsed_cmdline_options, kernel_version, result): # populate the checklist with data - populate_with_data(checklist, parsed_kconfig_options, 'kconfig') - populate_with_data(checklist, parsed_cmdline_options, 'cmdline') - populate_with_data(checklist, kernel_version, 'version') + if parsed_kconfig_options: + populate_with_data(checklist, parsed_kconfig_options, 'kconfig') + if parsed_cmdline_options: + populate_with_data(checklist, parsed_cmdline_options, 'cmdline') + if kernel_version: + populate_with_data(checklist, kernel_version, 'version') # now everything is ready, perform the checks perform_checks(checklist)