Commit Graph

267 Commits

Author SHA1 Message Date
Copilot e6743e4ab5 fix: add missing __init__.py to subpackages excluded from wheel installs (#2741)
* fix: add missing __init__.py to all subpackages lacking one

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: npmitche <40474174+npmitche@users.noreply.github.com>
2026-05-28 15:46:45 -07:00
Disconnect3d 3cf02e1198 Change file permission mode to octal format
Fix likely incorrect chmod permission since decimal numbers != hexadecimal numbers

TL;DR: I gave a talk on this here: https://www.youtube.com/watch?v=tRtxCCRdZOs&t=35227s
2026-04-30 14:15:36 -07:00
dscott90 32e2ba62c3 Add firmware data retrieval (#2710)
* Add firmware data retrieval
* Apply suggestions from code review
* Remove FW info native versions from linux/win helpers and added results to info module

---------

Signed-off-by: Dan Scott <dan.scott@intel.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2026-03-31 13:54:29 -07:00
William Leara 79f81bbb7e fix for flake8 rules related to whitespace
This commit fixes whitespace errors from checkers W291,W292,W293,W391.  They were found by running "flake8 ." from the root directory.  These are errors defined by "pycodestyle", and have no functional impact to the source.  This is simply fixing whitespace as defined by CHIPSEC's .flake8 configuration.

background:
https://www.flake8rules.com/rules/W291.html
https://www.flake8rules.com/rules/W292.html
https://www.flake8rules.com/rules/W293.html
https://www.flake8rules.com/rules/W391.html

tool versions: flake8 v7.3.0, python v3.13.11

Signed-off-by: William Leara <william.leara@dell.com>
2026-03-10 14:20:23 -07:00
Nathaniel Mitchell 789284e47f Add name to log error when reading uefi fars in linux
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2026-03-10 11:57:25 -07:00
Tamas K Lengyel 0f55fedd47 linuxhelper: assign default value if None is being passed in
linuxhelper's kern_set_EFI_variable only sets default value for attr if no
value has been passed in. In some call-chains (uefi var-write) however None
is being passed in, resulting in the following error from:

struct.error: required argument is not an integer

Make attr optional input and override if value is None with default value.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@oracle.com>
2026-01-29 11:59:38 -08:00
Tamas K Lengyel 1c30511638 Make uefi variable modification test more configurable
Currently the common.uefi.access_uefispec -a modify test modifications to variables
with the default variable attribute of nv | bs | rs (0x7). In this patch we make
this behavior more configurable.

By default the -a modify option will attempt to modify only the content of the variable,
but will not attempt to change the existing attributes of the variable. We have observed
cases where the test used this way uncovered more issues on variables where different
attributes were used and we did not attempt changing the attribute.

By specifying an optional attribute with -a modify,<attribute> the user can now test
variable modification with any attribute instead of just the currently hard-coded one.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@oracle.com>
2026-01-29 11:59:38 -08:00
Tamas K Lengyel 913c383b1a Convert str to byte object in linuxhelper's kern_set_EFI_variable (#2536)
* Convert str to byte object in linuxhelper's kern_set_EFI_variable

This is required to be able to successfuly run the common.uefi.access_uefispec -a modify
test from under Linux and resolve the following error:

ERROR: Exception occurred during chipsec.modules.common.uefi.access_uefispec.run(): 'argument for 's' must be a bytes object'

Signed-off-by: Tamas K Lengyel <tamas.lengyel@oracle.com>

* Use recommended best practice isinstance for type checking

Co-authored-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>

---------

Signed-off-by: Tamas K Lengyel <tamas.lengyel@oracle.com>
Co-authored-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2026-01-29 11:59:38 -08:00
William Leara c9b3f00344 remove unused imports from linuxhelper.py
These imports are not used within this module.  Also, fix tabs -> spaces.

Signed-off-by: William Leara <william.leara@dell.com>
2026-01-29 11:59:38 -08:00
Nathaniel Mitchell 914219e313 dev/chipsec2: Update dalhelper with correct cpuid calls
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2025-12-09 13:50:28 -08:00
Sara Batllori dadffd3d67 Updates to DAL helper
Signed-off-by: Sara Batllori <sara.batllori@intel.com>
2025-07-30 23:58:27 -07:00
Nathaniel Mitchell d5345ad8c1 mmio update, unit tests, additional fixes
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2025-03-04 22:15:21 -08:00
William Leara c1817d621f fix URL for pywin32
Python for Windows Extensions (pywin32) was migrated from SourceForge to GitHub 7 years ago.  Just quick update here to fix the referenced URL.  [no functional change to Chipsec implied in this commit]

Signed-off-by: William Leara <william.leara@dell.com>
2025-02-18 10:37:45 -08:00
Nathaniel Mitchell f077ebf68b Add error message on missing data when using the replayhelper
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2025-02-18 10:37:09 -08:00
BrentHoltsclaw 0165a61fec Dev/uefi hal (#2377)
* Add Win Cert types to uefi_fv and spi_uefi
* Move uefi search to library.uefi folder
* Move uefi_fv to library.uefi
* Move uefi_compression to library.uefi>
* Move uefi_common to library.uefi
* Move uefi_platform to library.uefi
* Move spi_uefi to library.uefi
* Add library.uefi.sleep_scripts file
* Move S3 functionality into sleep_state file
* Add varstore and variable files to library.uefi
* Fixup Flake8 suggestions
* Rename library uefi files to remove uefi_
* This change changes the filename of any file under the library.uefi to remove the uefi as part of the name.
* Fix Errors when testing changes

Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2025-02-12 09:13:50 -08:00
Nathaniel Mitchell f7409804b4 HAL Update - Enable multitenant HALs
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-12-03 12:50:36 -08:00
Nathaniel Mitchell c69509a92f Update functions that read efi variables from rom
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-09-25 12:39:17 -07:00
Nathaniel Mitchell 74fbfc7a10 Fix replay helper when bytes are stored
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-09-24 15:26:29 -07:00
Frinzell, Aaron 2181416bd9 Update type hints
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2024-09-10 16:38:28 -07:00
Frinzell, Aaron 926f9da4f6 Helper fstrings
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2024-08-28 13:58:42 -07:00
Nathaniel Mitchell 6e43a6edae Fix record/replay helpers to capture exceptions
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-08-26 16:38:52 -07:00
Dan Scott f19760c63c Replace print() with logger.log()
Signed-off-by: Dan Scott <dan.scott@intel.com>
2024-08-05 16:35:54 -07:00
jun2zhou 2f6e680c81 Remove empty () for helper banner (#2236)
* remove empty () for simic banner
* Move () to specified helper
---------

Signed-off-by: Jason Zhou <jun2.zhou@intel.com>
2024-07-30 14:22:31 -07:00
Nathaniel Mitchell aedaa7531f Fix bug when msgbus_cmd returns wrong value type in windows
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-07-30 14:12:32 -07:00
Nathaniel Mitchell 23f2eb517e Update Linux max phys mem write size from 0xFFFF to 0xFFFFFFFF
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-07-23 16:40:17 -07:00
Carles Pey 19e2553138 Add SMI enumeration mode to the smm_ptr module (#2141)
* Add SMI enumeration mode to the smm_ptr module

Signed-off-by: Carles Pey <carles.pey@nccgroup.com>
2024-05-29 10:19:42 -07:00
Nathaniel Mitchell ed9c6e2896 Update how ACPI Tables are found
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-04-17 15:27:21 -07:00
Nathaniel Mitchell 3b5a0a69d1 Fix missing 'f' in f-strings
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-03-28 10:35:30 -07:00
Nathaniel Mitchell 987bd3b7a1 Update error when running 'uefi var-list' cmd
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-03-28 10:32:39 -07:00
Dan Scott 0e8192cfd0 Move files to library folder 2024-03-22 14:26:59 -07:00
Dan Scott a933b1337d Update references to functions in new library files 2024-03-22 14:26:59 -07:00
Dan Scott 4584c67e80 Update attribute assignment conditons for set_EFI_variable 2024-02-12 16:36:38 -08:00
corentin 7bdf194f9e LinuxHelper: open the device with buffering=0 to avoid caching when reading physical memory 2024-02-06 16:38:42 -08:00
Nathaniel Mitchell fbccec7756 Fix import and possible unbound errors
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-10-16 16:38:21 -07:00
Nathaniel Mitchell 6a23a6e968 Add initial windows helper unit tests
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-09-29 09:20:39 -07:00
Nathaniel Mitchell e3b4473bad Update assertRegexpMatch to assertRegex and base Helper to NoneHelper
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-08-21 16:36:12 -07:00
Nathaniel Mitchell 96d5409688 Update BaseCommand, chipsec_util with new util structure
Additional changes to enhance utils usage

Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-07-27 11:39:28 -07:00
Nathaniel Mitchell c3b27e7870 Add record and replay helpers
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-07-26 15:31:56 -07:00
Nathaniel Mitchell 9a09eaed07 Fix 'self._get_driver_handle()' function calls in windowshelper.py
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-07-25 16:38:50 -07:00
Nathaniel Mitchell 27ee5eeb66 Clean up helper create/start/stop/delete functions
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-07-19 16:33:59 -07:00
Nicolas Iooss d04cabd02d Remove invalid escape sequences in Windows path
`windowshelper.py` uses a path with backslashes without proper escaping.
While this works because `\s` and `\c` are not valid escape sequences,
this makes flake8 report:

   /chipsec/helper/windows/windowshelper.py:71:53: W605 invalid escape sequence '\s'
   /chipsec/helper/windows/windowshelper.py:71:67: W605 invalid escape sequence '\c'

Fix this by splitting the path when invoking `os.path.join`.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-07-11 16:37:03 -07:00
Nicolas Iooss f1dfa2dcdd Remove from_file from method start in base helper
Commit 99f9052438 ("Remove filehelper") removed `from_file` and
`to_file` from `OsHelper` but it remained in `BaseHelper`. Remove these
parameters too.

While at it, remove the similar parameters from the mock helper used in
tests.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-07-10 16:42:07 -07:00
Nathaniel Mitchell ede85bfcbf Fix mocked module scoping issue in unittest
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-06-26 16:36:48 -07:00
Frinzell, Aaron 41ecf2cdb1 Implement basehelper.py as an ABC
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2023-06-23 08:27:17 -07:00
Nathaniel Mitchell 5940959a19 Refactor msgbus_send_read/write_message to use msgbus_send_message
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-06-21 16:41:21 -07:00
Nicolas Iooss 6d52c2c54f Add type hints to helper.linuxnative.cpuid
With these annotations, mypy no longer report any issues in strict mode:

    $ mypy --strict chipsec/helper/linuxnative/cpuid.py
    Success: no issues found in 1 source file

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-06-20 16:37:01 -07:00
Nicolas Iooss f0ebbe01cc Simplify CPUID code mapping in linuxnative helper
Make the machine code `bytes` instead of `list`. This makes it no longer
necessary to cast it to `c_ubyte * size` before using it.

While at it, add `mmap.MAP_PRIVATE` flag to the mapping, as it is not
needed to create a `MAP_SHARED` mapping for the code (which is the
default flag).

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-06-20 16:37:01 -07:00
Nicolas Iooss fb80548746 Remove print_function import
Now that chipsec is no longer compatible with Python2, this import is no
longer useful.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-06-20 16:37:01 -07:00
Nicolas Iooss 14c5f7c314 Directly import chipsec.helper.linuxnative.cpuid in linuxnative
There is no point in doing a lazy-import with
`chipsec.helper.linuxnative.cpuid`, as the `cpuid` function is almost
always called when starting chipsec, to display the banner.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-06-20 16:37:01 -07:00
Nicolas Iooss 470820d464 Use c_void_p instead of c_voidp
`ctypes.c_voidp` was a bug which is kept in ctypes for backward
compatibility. This is documented in
https://github.com/python/cpython/blob/3.10/Lib/ctypes/__init__.py#L246
:

    c_voidp = c_void_p # backwards compatibility (to a bug)

Replace the use of `c_voidp` with `c_void_p`.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-06-20 16:37:01 -07:00