From 575ae82ab6ca197a5fd502ecddc548f76d20cb4a Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Mon, 14 Aug 2023 18:56:13 +0300 Subject: [PATCH] Test an unexpected line in the sysctl file --- .github/workflows/functional_test.sh | 5 +++++ kconfig_hardened_check/__init__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/functional_test.sh b/.github/workflows/functional_test.sh index a4fb085..cbacf87 100644 --- a/.github/workflows/functional_test.sh +++ b/.github/workflows/functional_test.sh @@ -125,4 +125,9 @@ echo 'hey man 1' > cmdline echo 'hey man 2' >> cmdline coverage run -a --branch bin/kconfig-hardened-check -c test.config -l cmdline && exit 1 +echo ">>>>> unexpected line in the sysctl file <<<<<" +cp $SYSCTL_EXAMPLE error_sysctls +echo 'some strange line' >> error_sysctls +coverage run -a --branch bin/kconfig-hardened-check -c test.config -s error_sysctls && exit 1 + echo "The end of the functional tests" diff --git a/kconfig_hardened_check/__init__.py b/kconfig_hardened_check/__init__.py index d7df1bf..3e4db1c 100644 --- a/kconfig_hardened_check/__init__.py +++ b/kconfig_hardened_check/__init__.py @@ -205,7 +205,7 @@ def parse_sysctl_file(mode, parsed_options, fname): for line in f.readlines(): line = line.strip() if not sysctl_pattern.match(line): - sys.exit(f'[!] ERROR: unexpected line in sysctl file: {line}') + sys.exit(f'[!] ERROR: unexpected line in sysctl file: "{line}"') option, value = line.split('=', 1) option = option.strip() value = value.strip() -- 2.31.1