From: Alexander Popov Date: Mon, 13 May 2024 13:26:42 +0000 (+0300) Subject: Fix assertion style X-Git-Tag: v0.6.10~67^2~11 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=d7d76b05572c93e89f2ac911cb0790c0140dd3da;p=kconfig-hardened-check.git Fix assertion style Make assertions look similarly. --- diff --git a/kernel_hardening_checker/__init__.py b/kernel_hardening_checker/__init__.py index 3a30aef..7db9e40 100644 --- a/kernel_hardening_checker/__init__.py +++ b/kernel_hardening_checker/__init__.py @@ -367,7 +367,7 @@ def main() -> None: if mode and mode not in ('verbose', 'json'): sys.exit(f'[!] ERROR: wrong mode "{mode}" for --print') arch = args.print - assert arch, 'unexpected empty arch from ArgumentParser' + assert(arch), 'unexpected empty arch from ArgumentParser' add_kconfig_checks(config_checklist, arch) add_cmdline_checks(config_checklist, arch) add_sysctl_checks(config_checklist, arch) @@ -377,11 +377,15 @@ def main() -> None: sys.exit(0) if args.generate: - assert(args.config is None and args.cmdline is None and args.sysctl is None and args.print is None), 'unexpected args' + assert(args.config is None and + args.cmdline is None and + args.sysctl is None and + args.print is None), \ + 'unexpected args' if mode: sys.exit(f'[!] ERROR: wrong mode "{mode}" for --generate') arch = args.generate - assert arch, 'unexpected empty arch from ArgumentParser' + assert(arch), 'unexpected empty arch from ArgumentParser' add_kconfig_checks(config_checklist, arch) print(f'CONFIG_{arch}=y') # the Kconfig fragment should describe the microarchitecture for opt in config_checklist: diff --git a/kernel_hardening_checker/engine.py b/kernel_hardening_checker/engine.py index 1c1f0c6..2a371e4 100644 --- a/kernel_hardening_checker/engine.py +++ b/kernel_hardening_checker/engine.py @@ -126,7 +126,7 @@ class OptCheck: "reason": self.reason, } # type: Dict[str, StrOrBool] if with_results: - assert self.result, f'unexpected empty result in {self.name}' + assert(self.result), f'unexpected empty result in {self.name}' dump["check_result"] = self.result dump["check_result_bool"] = self.result.startswith('OK') return dump @@ -246,7 +246,7 @@ class ComplexOptCheck: dump = self.opts[0].json_dump(False) if with_results: # Add the 'check_result' and 'check_result_bool' keys to the dictionary - assert self.result, f'unexpected empty result in {self.name}' + assert(self.result), f'unexpected empty result in {self.name}' dump["check_result"] = self.result dump["check_result_bool"] = self.result.startswith('OK') return dump