Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REBASE&FF][CHERRY-PICK] ImageValidation: Add default configuration #1104

Merged

Conversation

Javagedes
Copy link
Contributor

Previously, ImageValidation was an "opt-in" plugin by setting a build variable PE_VALIDATION_PATH, however with this pull request, Image Validation will be on by default, with some default configuration that can be changed with a custom configuration yaml file.

The default requirements are:

  1. All efi binaries must not be both write and execute
  2. All efi binaries must have an image base of 0x0
  3. All dxe phase binaries must be 4k section aligned, with the one exception of AARCH64 DXE_RUNTIME_DRIVERS, which must be 64k aligned.

compiled binaries that need to be opted out of, can do so by adding an IGNORE_LIST in the configuration file

{
  "IGNORE_LIST": ["Shell.efi", "etc"]
}

A cherry-pick of #1100 into release/202311

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

How This Was Tested

Confirmed successful execution of the plugin on Windows with QemuQ35 and Ubuntu with QemuSbsa

Integration Instructions

Platforms that begin to fail this test will need to generate a configuration yaml file, and set a stuart build variable, PE_VALIDATION_PATH to it. It is suggested to do this in the Platform's PlatformBuild.py.

The Correct Integration is to evaluate the binary and why it is not meeting the requirements. The platform can elect to update the compilation of the binary to meet the requirements, add or override validation rules for certain MODULE_TYPEs, or simply add the binary to the ignore list. Please review the Plugin's readme.md file for more details on doing any of these things.

Previously, ImageValidation was an "opt-in" plugin by setting a build
variable `PE_VALIDATION_PATH`, however with this pull request, Image
Validation will be on by default, with some default configuration that
can be changed with a custom configuration yaml file.

The default requirements are:
1. All efi binaries must not be both write and execute
2. All efi binaries must have an image base of 0x0
3. All dxe phase binaries must be 4k section aligned, with the one
exception of AARCH64 DXE_RUNTIME_DRIVERS, which must be 64k aligned.

compiled binaries that need to be opted out of, can do so by adding an
`IGNORE_LIST` in the configuration file

```json
{
  "IGNORE_LIST": ["Shell.efi", "etc"]
}
```

- [ ] Impacts functionality?
- **Functionality** - Does the change ultimately impact how firmware
functions?
- Examples: Add a new library, publish a new PPI, update an algorithm,
...
- [ ] Impacts security?
- **Security** - Does the change have a direct security impact on an
application,
    flow, or firmware?
  - Examples: Crypto algorithm change, buffer overflow fix, parameter
    validation improvement, ...
- [x] Breaking change?
- **Breaking change** - Will anyone consuming this change experience a
break
    in build or boot behavior?
- Examples: Add a new library class, move a module to a different repo,
call
    a function in a new library class in a pre-existing module, ...
- [ ] Includes tests?
  - **Tests** - Does the change include any explicit test code?
  - Examples: Unit tests, integration tests, robot tests, ...
- [x] Includes documentation?
- **Documentation** - Does the change contain explicit documentation
additions
    outside direct code modifications (and comments)?
- Examples: Update readme file, add feature readme file, link to
documentation
    on an a separate Web page, ...

Confirmed successful execution of the plugin on Windows with QemuQ35 and
Ubuntu with QemuSbsa

Platforms that begin to fail this test will need to generate a
configuration yaml file, and set a stuart build variable,
`PE_VALIDATION_PATH` to it. It is suggested to do this in the Platform's
`PlatformBuild.py`.

**The Correct Integration** is to evaluate the binary and why it is not
meeting the requirements. The platform can elect to update the
compilation of the binary to meet the requirements, add or override
validation rules for certain MODULE_TYPEs, or simply add the binary to
the ignore list. Please review the Plugin's readme.md file for more
details on doing any of these things.

---------

Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
Co-authored-by: Michael Kubacki <michael.kubacki@microsoft.com>
@github-actions github-actions bot added impact:breaking-change Requires integration attention impact:non-functional Does not have a functional impact type:documentation Improvements or additions to documentation labels Aug 12, 2024
@Javagedes Javagedes requested a review from os-d August 12, 2024 15:13
@Javagedes Javagedes self-assigned this Aug 12, 2024
@Javagedes Javagedes requested a review from apop5 August 12, 2024 15:34
@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 1.35%. Comparing base (583c20c) to head (f9e5576).

Additional details and impacted files
@@               Coverage Diff               @@
##           release/202311    #1104   +/-   ##
===============================================
  Coverage            1.35%    1.35%           
===============================================
  Files                1303     1303           
  Lines              333838   333838           
  Branches             5103     5103           
===============================================
  Hits                 4512     4512           
  Misses             329243   329243           
  Partials               83       83           
Flag Coverage Δ
MdeModulePkg 0.68% <ø> (ø)
MdePkg 5.40% <ø> (ø)
NetworkPkg 0.55% <ø> (ø)
PolicyServicePkg 30.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Javagedes Javagedes merged commit 87e39fa into microsoft:release/202311 Aug 12, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact:breaking-change Requires integration attention impact:non-functional Does not have a functional impact type:documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants