From cb0711d4a1561cfe5fb8bbe2130c255d2cbe1479 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Fri, 20 Jul 2018 19:00:20 +0300 Subject: [PATCH] Fix the check against multiple options in config file --- kconfig-hardened-check.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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() -- 2.31.1