From: Alexander Popov Date: Wed, 4 Sep 2024 13:21:31 +0000 (+0300) Subject: sysctl parsing: Allow comments (they usually exist in sysctl.conf) X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=e6efa5663944028c6b5d0b07222ff845fc5223b9;p=kconfig-hardened-check.git sysctl parsing: Allow comments (they usually exist in sysctl.conf) --- 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)