Skip to content

Added more comprehensive support to inspect bootloader configuration#404

Merged
magerstam merged 14 commits intomainfrom
bootloader-inspect
Feb 24, 2026
Merged

Added more comprehensive support to inspect bootloader configuration#404
magerstam merged 14 commits intomainfrom
bootloader-inspect

Conversation

@magerstam
Copy link
Copy Markdown
Contributor

@magerstam magerstam commented Feb 12, 2026

Merge Checklist

All boxes should be checked before merging the PR

  • The changes in the PR have been built and tested
  • Ready to merge

Description

This commit completes the bootloader configuration inspection feature by adding comprehensive comparison, diffing, and rendering capabilities. It integrates bootloader configuration changes into the semantic equality assessment system, enabling intelligent classification of changes as meaningful (functional) versus volatile (build artifacts).

Key Functionality Added

  1. Bootloader Config Comparison & Diff Tracking
  • Automatic detection of bootloader configuration changes when comparing images
  • Structured diff format capturing:
    • Config file changes (grub.cfg, systemd-boot entries, etc.)
    • Boot menu entry modifications (kernel path, cmdline, initrd)
    • Kernel reference changes with partition UUID tracking
    • UUID validation and mismatch detection
  1. Intelligent Diff Classification
    Categorizes bootloader config changes for accurate semantic equality assessment:

Meaningful Changes (functional impact - affects boot behavior):

  • Config files added/removed/modified
  • Boot entries added/removed
  • Kernel path changes (e.g., /vmlinuz-5.14/vmlinuz-5.15)
  • Kernel cmdline changes after normalization (e.g., new boot parameters)
  • Kernel references added/removed
  • UUID mismatches introduced or fixed (validation errors)

Volatile Changes (expected build variations):

  • Boot entry cosmetic changes (titles, descriptions)
  • Partition/filesystem UUID regeneration (random per-build)
  • UUID reference context changes without validation issues
  • Configuration notes/warnings
  1. Enhanced Bootloader Config Parser
  • Better GRUB config parsing (menuentry detection, kernel cmdline extraction)
  • Improved systemd-boot .conf parsing
  • UUID extraction and validation against actual partition table
  • Root device detection (root=UUID=..., root=PARTUUID=...)
  1. Text Renderer Updates
  • Uses pre-computed m.BootConfig diff (consistent with UKI diff pattern)
  • Displays bootloader config changes alongside EFI binary modifications
  • Shows config file hash changes
  • Highlights boot entry modifications with kernel and cmdline diffs
  • Warns about UUID mismatches with ✗ CRITICAL markers
  1. Filesystem Raw Access Enhancements
  • Better handling of bootloader config file locations
  • Support for reading files from various partition types (VFAT, ext4, squashfs)
  • Improved error handling and edge case coverage

Usage Example

Example output for bootloader config parsing

Bootloader configuration
------------------------
Boot entries:
  * [1] UKI Boot Entry
       kernel: EFI/Linux/linux-6.12.61-2.emt3.efi
       root:   /dev/mapper/rootfs_verity
       cmdline: root=/dev/mapper/rootfs_verity boot_uuid=343c39c7-3fb5-486d-9703-28d89a1ee56f security=selinux se...
Kernel references:
  EFI/Linux/linux-6.12.61-2.emt3.efi
    root uuid:      /dev/mapper/rootfs_verity
    boot entry:     UKI Boot Entry
Notes:
  - Boot configuration extracted from UKI binary EFI/Linux/linux-6.12.61-2.emt3.efi (no loader.conf found)

Bootloader configuration
------------------------
Notes:
  - No GRUB configuration file found on ESP. Some distributions may store GRUB config on the root partition (/boot/grub/grub.cfg)
Notes:
  - diskfs GetFilesystem(1) failed: unknown filesystem on partition 1
  - FAT BPB: BytsPerSec=512 SecPerClus=16 Rsvd=16 NumFATs=2 RootEntCnt=512 TotSec16=0 TotSec32=784350 FATSz16=192 FATSz32=2418606208

Any Newly Introduced Dependencies

How Has This Been Tested?

New Test Coverage:

  • bootloader_config_test.go - +428 lines of comprehensive test cases
  • Tests for GRUB menuentry parsing
  • Tests for systemd-boot entry parsing
  • Tests for UUID mismatch detection
  • Comparison diff tests

@magerstam magerstam marked this pull request as ready for review February 17, 2026 23:47
Copilot AI review requested due to automatic review settings February 17, 2026 23:47
@magerstam magerstam requested a review from a team as a code owner February 17, 2026 23:47
@magerstam magerstam requested a review from arodage February 17, 2026 23:47
@magerstam magerstam added the enhancement New feature or request label Feb 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the image inspection/comparison subsystem to extract, represent, diff, classify, and render bootloader configuration changes (GRUB/systemd-boot/UKI-derived) as part of EFI evidence and semantic equality assessment.

Changes:

  • Add BootloaderConfig / BootloaderConfigDiff structures and integrate them into EFI evidence, comparison diffs, and equality tallying.
  • Extract bootloader config data from raw FAT/ESP reads (plus UKI-based synthesis) and parse basic GRUB + loader.conf content.
  • Render bootloader config details and diffs in the text renderer, and add comprehensive unit tests around parsing/validation/diffing.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
internal/image/imageinspect/renderer_text.go Renders bootloader config details per image and bootloader config diffs during comparisons.
internal/image/imageinspect/imageinspect.go Introduces core BootloaderConfig/related types and adds hashBytesHex helper.
internal/image/imageinspect/helpers_test.go Updates hashing test to use hashBytesHex.
internal/image/imageinspect/fs_raw.go Extracts bootloader config from ESP FAT volume and synthesizes config from UKI cmdline when applicable.
internal/image/imageinspect/compare_efi.go Computes structured diffs for bootloader config changes.
internal/image/imageinspect/compare.go Adds bootloader config diffs into semantic diff tallying (meaningful vs volatile).
internal/image/imageinspect/bootloader_efi.go Switches PE hashing to hashBytesHex and adds a bootloader config path helper.
internal/image/imageinspect/bootloader_config.go Adds GRUB/systemd-boot parsing + UUID extraction/validation utilities.
internal/image/imageinspect/bootloader_config_test.go Adds tests for parsing, diffing, UUID resolution, validation, and UKI synthesis.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/image/imageinspect/fs_raw.go Outdated
Comment thread internal/image/imageinspect/bootloader_config.go Outdated
Comment thread internal/image/imageinspect/bootloader_config.go Outdated
Comment thread internal/image/imageinspect/compare_efi.go
Comment thread internal/image/imageinspect/compare_efi.go
Comment thread internal/image/imageinspect/renderer_text.go Outdated
Comment thread internal/image/imageinspect/renderer_text.go
Comment thread internal/image/imageinspect/bootloader_efi.go Outdated
magerstam and others added 3 commits February 18, 2026 09:13
In renderBootloaderConfigDiffText, CmdlineTo could be shorter than 77
chars when CmdlineFrom was >80, causing an index out of range panic.
Each string is now truncated independently.
When both Mismatch and Context differed for the same UUID,
compareUUIDReferences silently dropped the context change. Merged
the two separate if-blocks into a single condition that produces
one change entry carrying both deltas. Added test assertion.
@arodage
Copy link
Copy Markdown
Contributor

arodage commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

@arodage arodage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@magerstam magerstam merged commit 63a14f9 into main Feb 24, 2026
36 checks passed
@magerstam magerstam deleted the bootloader-inspect branch February 24, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants