X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=kernel_hardening_checker%2F__init__.py;h=614084e4e3a7ac7af704e76f4b7b2c6fd01ca4a5;hb=35fb52c57d444f55e3ce59771bfb61009479c33c;hp=bb4af6c1fedeb5991df48a57eaa42424445a9920;hpb=d36db02bcefd3f132215ab05cbcaa36f3c5e3865;p=kconfig-hardened-check.git diff --git a/kernel_hardening_checker/__init__.py b/kernel_hardening_checker/__init__.py index bb4af6c..614084e 100644 --- a/kernel_hardening_checker/__init__.py +++ b/kernel_hardening_checker/__init__.py @@ -8,7 +8,7 @@ Author: Alexander Popov This module performs input/output. """ -# pylint: disable=missing-function-docstring,line-too-long,invalid-name,too-many-branches,too-many-statements +# pylint: disable=missing-function-docstring,line-too-long,too-many-branches,too-many-statements import gzip import sys @@ -16,16 +16,22 @@ from argparse import ArgumentParser from typing import List, Tuple, Dict, TextIO import re import json -from .__about__ import __version__ from .checks import add_kconfig_checks, add_cmdline_checks, normalize_cmdline_options, add_sysctl_checks from .engine import StrOrNone, TupleOrNone, ChecklistObjType from .engine import print_unknown_options, populate_with_data, perform_checks, override_expected_value +# kernel-hardening-checker version +__version__ = '0.6.6' + + def _open(file: str) -> TextIO: - if file.endswith('.gz'): - return gzip.open(file, 'rt', encoding='utf-8') - return open(file, 'rt', encoding='utf-8') + try: + if file.endswith('.gz'): + return gzip.open(file, 'rt', encoding='utf-8') + return open(file, 'rt', encoding='utf-8') + except FileNotFoundError: + sys.exit(f'[!] ERROR: unable to open {file}, are you sure it exists?') def detect_arch(fname: str, archs: List[str]) -> Tuple[StrOrNone, str]: