From: Alexander Popov Date: Fri, 20 Jul 2018 16:00:20 +0000 (+0300) Subject: Fix the check against multiple options in config file X-Git-Tag: v0.5.2~88^2~9 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=cb0711d4a1561cfe5fb8bbe2130c255d2cbe1479;p=kconfig-hardened-check.git Fix the check against multiple options in config file --- diff --git a/kconfig-hardened-check.py b/kconfig-hardened-check.py index a239836..949c19a 100755 --- a/kconfig-hardened-check.py +++ b/kconfig-hardened-check.py @@ -198,19 +198,21 @@ def check_config_file(fname): print('[+] Checking "{}" against hardening preferences...'.format(fname)) for line in f.readlines(): line = line.strip() + option = None + value = None if opt_is_on.match(line): - config, value = line[7:].split('=', 1) - parsed_options[config] = value + option, value = line[7:].split('=', 1) elif opt_is_off.match(line): - config, value = line[9:].split(' ', 1) + option, value = line[9:].split(' ', 1) if value != 'is not set': sys.exit('[!] BUG: bad disabled config option "{}"'.format(line)) - if config in parsed_options: - sys.exit('[!] ERROR: config option "{}" exists multiple times'.format(line)) + if option in parsed_options: + sys.exit('[!] ERROR: config option "{}" exists multiple times'.format(line)) - parsed_options[config] = value + if option is not None: + parsed_options[option] = value check_state(parsed_options) print_check_results()