Files
chipsec-chipsec/tests/modules/run_chipsec_module.py
T
William Leara 5ffa64907d fix for flake8 rule E302
This commit fixes all the E302 errors.  They were found by running "flake8 ." from the root directory.  This is an error defined by "pycodestyle", and has no functional impact to the source.  This is simply fixing whitespace as defined by CHIPSEC's .flake8 configuration.

background:
https://www.flake8rules.com/rules/E302.html
https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes:~:text=line%2C%20found%200-,E302,-expected%202%20blank

versions: flake8 v7.2.0, python v3.12.6

Signed-off-by: William Leara <william.leara@dell.com>
2025-04-30 12:02:15 -07:00

60 lines
2.4 KiB
Python

# CHIPSEC: Platform Security Assessment Framework
# Copyright (c) 2023, Intel Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; Version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Contact information:
# chipsec@intel.com
#
from unittest.mock import Mock
import chipsec.helper.replay.replayhelper as rph
from chipsec_main import ChipsecMain, parse_args
import chipsec.chipset as cs
import chipsec.library.logger
def run_chipsec_module(csm: ChipsecMain, module_replay_file: str) -> int:
csm._cs.init(csm._platform, csm._pch, csm._helper, not csm._no_driver, csm._load_config, csm._ignore_platform)
if module_replay_file:
csm._helper.config_file = module_replay_file
csm._helper._load()
csm.load_module(csm._module, csm._module_argv)
ret = csm.run_loaded_modules()
return ret
def setup_run_destroy_module_with_mock_logger(init_replay_file: str, module_str: str, module_args: str = "", module_replay_file: str = "") -> int:
chipsec.library.logger._logger.remove_chipsec_logger()
chipsec.library.logger._logger = Mock()
chipsec.library.logger._logger.VERBOSE = False
chipsec.library.logger._logger.DEBUG = False
chipsec.library.logger._logger.HAL = False
retval = setup_run_destroy_module(init_replay_file, module_str, module_args, module_replay_file)
chipsec.library.logger._logger = chipsec.library.logger.Logger()
return retval
def setup_run_destroy_module(init_replay_file: str, module_str: str, module_args: str = "", module_replay_file: str = "") -> int:
arg_str = f" {module_args}" if module_args else ""
cli_cmds = f"-m {module_str}{arg_str}".strip().split(' ')
cs._chipset = None
par = parse_args(cli_cmds)
csm = ChipsecMain(par, cli_cmds)
replayHelper = rph.ReplayHelper(init_replay_file)
csm._helper = replayHelper
return run_chipsec_module(csm, module_replay_file)