From e6efa5663944028c6b5d0b07222ff845fc5223b9 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Wed, 4 Sep 2024 16:21:31 +0300 Subject: [PATCH] sysctl parsing: Allow comments (they usually exist in sysctl.conf) --- kernel_hardening_checker/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel_hardening_checker/__init__.py b/kernel_hardening_checker/__init__.py index e0f1c97..4fe2ef2 100755 --- a/kernel_hardening_checker/__init__.py +++ b/kernel_hardening_checker/__init__.py @@ -209,6 +209,8 @@ def parse_sysctl_file(mode: StrOrNone, parsed_options: Dict[str, str], fname: st sysctl_pattern = re.compile(r"[a-zA-Z0-9/\._-]+ ?=.*$") for line in f.readlines(): line = line.strip() + if line.startswith('#'): + continue if not sysctl_pattern.match(line): sys.exit(f'[!] ERROR: unexpected line in sysctl file: "{line}"') option, value = line.split('=', 1) -- 2.31.1