-
Notifications
You must be signed in to change notification settings - Fork 13
Introduce UEFI Firmware Analyzer #93
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
Open
gahan9
wants to merge
1
commit into
intel:main
Choose a base branch
from
gahan9:data_analysis
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # UEFI Firmware Analyzer | ||
|
|
||
| The UEFI Firmware Analyzer is a comprehensive tool within the `xml-cli` framework designed to parse, analyze, and visualize the structure and space utilization of UEFI firmware binaries. | ||
|
|
||
| ## Features | ||
|
|
||
| - **Physical Flash Analysis**: Calculates space occupancy based on the actual flash layout (32MB/16MB/etc). | ||
| - **Deep Analysis Mode**: Visualizes decompressed components, providing a "logical" view of the firmware (often exceeding the physical size due to decompression). | ||
| - **Interactive Dashboard**: A self-contained HTML report with dynamic charts, progress bars for every level of hierarchy, and real-time search. | ||
| - **Smart Search**: Search by Driver Name, GUID, or `FileNameString`. Matching items are automatically expanded for easy discovery. | ||
| - **Address Mapping**: Displays absolute hexadecimal start and end address ranges for every component in the hierarchy. | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### 1. Command Line (Unified Flow) | ||
| You can analyze a **binary firmware** or an **existing JSON report** in one command: | ||
| ```powershell | ||
| # Run the analysis (if installed in environment) | ||
| uefi-analyze "C:\path\to\bios.bin" | ||
| ``` | ||
| *Note: This generates the JSON, calculates metrics, and automatically opens your browser.* | ||
|
|
||
| ### 2. Windows Context Menu | ||
| Analyze any `.bin`, `.rom`, `.fd`, or `.json` file directly from Windows Explorer: | ||
| 1. **Install Menu**: Run `python src/xmlcli/modules/winContextMenu/install_context_menu.py`. | ||
| 2. **Right-Click**: Select `XmlCli Menu` > `Analyze UEFI Firmware and View`. | ||
| 3. **Result**: The tool detects the file type and opens the interactive dashboard immediately. | ||
|
|
||
| ## Advanced Workflow | ||
|
|
||
| If you need to perform steps manually: | ||
|
|
||
| ### Step 1: Parse the Binary to JSON | ||
| ```python | ||
| from xmlcli.common.bios_fw_parser import UefiParser | ||
| parser = UefiParser(bin_file="path/to/bios.bin") | ||
| output_dict = parser.parse_binary() | ||
| parser.write_result_to_file("output.json", output_dict=output_dict) | ||
| ``` | ||
|
|
||
| ### Step 2: Generate the Analysis Dashboard | ||
| ```powershell | ||
| uefi-analyze "C:\path\to\output.json" | ||
| ``` | ||
|
|
||
| ## Output Locations | ||
| Results (JSON and HTML) are saved to: | ||
| - `C:\Users\<user>\AppData\Local\Temp\XmlCliOut\logs\result\analytic_view\` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # coding=utf-8 | ||
| """ | ||
| UEFI Analyzer Module | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # coding=utf-8 | ||
| """ | ||
| Entry point for BIOS Analysis and View Generation | ||
| """ | ||
| import os | ||
| import sys | ||
| import argparse | ||
| import tempfile | ||
| from xmlcli.modules.uefi_analyzer import bios_analyzer | ||
| from xmlcli.modules.uefi_analyzer import report_generator | ||
| from xmlcli.common import configurations | ||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser(description="BIOS Analysis View Generator") | ||
| parser.add_argument("json_files", nargs="+", help="JSON files produced by UefiParser") | ||
| parser.add_argument("--output-dir", help="Directory to store analysis results") | ||
| args = parser.parse_args() | ||
|
|
||
| # Determine output directory | ||
| # User requested temp workspace in LOG_FILE_LOCATION as directory result analytic_view | ||
| # Based on configurations.py and logger.py, we can construct this. | ||
|
|
||
| log_dir = os.path.join(configurations.OUT_DIR, "logs") | ||
| default_output_dir = os.path.join(log_dir, "result", "analytic_view") | ||
|
|
||
| # Also consider the temp workspace as requested | ||
| temp_workspace = os.path.join(tempfile.gettempdir(), "XmlCliOut", "logs", "result", "analytic_view") | ||
|
|
||
| output_dir = args.output_dir or temp_workspace | ||
|
|
||
| if not os.path.exists(output_dir): | ||
| os.makedirs(output_dir) | ||
|
|
||
| print(f"Analyzing {len(args.json_files)} files...") | ||
| analyzer = bios_analyzer.BiosAnalyzer(args.json_files) | ||
| analysis_results = analyzer.analyze_all() | ||
|
|
||
| # Save the raw analysis JSONs | ||
| analyzer.save_analysis(output_dir) | ||
|
|
||
| # Generate the HTML dashboard | ||
| report_file = os.path.join(output_dir, "dashboard.html") | ||
| report_generator.generate_report(analysis_results, report_file) | ||
|
|
||
| print(f"Analysis complete.") | ||
| print(f"Results saved to: {output_dir}") | ||
| print(f"Dashboard available at: {report_file}") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help text should clarify the expected file format or provide an example path. Currently 'JSON files produced by UefiParser' is vague for users unfamiliar with the tool's output format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commentary Suggetion only. Not applicable