Help us shape the future of Go! Take the 2026 Go Developer Survey

diff

package
v2.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: BSD-3-Clause Imports: 13 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalysisReport

type AnalysisReport struct {
	// Entries contains each block with different data.
	Entries AnalysisReportEntries

	// AddressMapper converts the address in DiffRange into a position in the SystemArtifact.
	AddressMapper types.AddressMapper

	// FirstProblemOffset is the offset of the first byte with a different value.
	FirstProblemOffset uint64

	// BytesChanged is a count of bytes with different values.
	BytesChanged uint64

	// HammingDistance is a bit-wise hamming distance between images.
	HammingDistance uint64

	// HammingDistanceNon00orFF is a bit-wise hamming distance between images, excluding
	// bytes 0x00 and 0xff
	HammingDistanceNon00orFF uint64
}

AnalysisReport contains an analyzed report for an UEFI image diff.

func Analyze

func Analyze(
	diffMemRanges Ranges,
	memMapper types.AddressMapper,
	measurements Measurements,
	goodFirmware, badFirmware *biosimage.BIOSImage,
) (report AnalysisReport, err error)

Analyze generates a difference report filled with additional simple analytics, like hamming distance.

func (*AnalysisReport) AddOffset

func (report *AnalysisReport) AddOffset(offset int64)

AddOffset just adds the offset to all offsets of the report

type AnalysisReportEntries

type AnalysisReportEntries []AnalysisReportEntry

AnalysisReportEntries is a set of multiple AnalysisReportEntry-ies.

func (AnalysisReportEntries) DiffRanges

func (s AnalysisReportEntries) DiffRanges() pkgbytes.Ranges

DiffRanges returns DiffRange-s.

type AnalysisReportEntry

type AnalysisReportEntry struct {
	// DiffRange is the information about offsets where the data is different.
	DiffRange pkgbytes.Range

	// HammingDistance is a bit-wise hamming distance between the data blocks.
	HammingDistance uint64

	// HammingDistanceNon00orFF is a bit-wise hamming distance between the data
	// blocks, excluding bytes 0x00 and 0xff
	HammingDistanceNon00orFF uint64

	// RelatedMeasurements contains the list of measurements which overlaps
	// with the data block.
	RelatedMeasurements []RelatedMeasurement

	// Nodes contains the list of UEFI nodes (regions, volumes, modules, files)
	// which overlaps with the data block
	Nodes []NodeInfo
}

AnalysisReportEntry contains information about on block with different data.

type DataChunk added in v2.8.0

type DataChunk struct {
	Description   string
	ForceBytes    []byte
	Reference     pkgbytes.Range
	AddressMapper types.AddressMapper
	CustomData    any
}

type DataChunks added in v2.8.0

type DataChunks []DataChunk

type Firmware

type Firmware interface {
	Buf() []byte
	GetByRange(byteRange pkgbytes.Range) (nodes []*ffs.Node, err error)
	NameToRangesMap() map[string]pkgbytes.Ranges
}

Firmware is an abstraction over *uefi.UEFI

type Measurement added in v2.8.0

type Measurement struct {
	Description string
	Chunks      DataChunks
	CustomData  any
}

type Measurements added in v2.8.0

type Measurements []Measurement

type NodeInfo

type NodeInfo struct {
	UUID        uuid.UUID
	Description string
}

NodeInfo is a struct contains information about one UEFI FFS node.

func (NodeInfo) String

func (nodeInfo NodeInfo) String() string

String implements fmt.Stringer

type NodeInfos

type NodeInfos []NodeInfo

NodeInfos is a slice of NodeInfo-s

func GetNodesInfo

func GetNodesInfo(nodes []*ffs.Node) NodeInfos

GetNodesInfo converts nodes to structures ready for human-readable printing.

TODO: move this to a "format" package

func (NodeInfos) String

func (s NodeInfos) String() string

String implements fmt.Stringer

type Range added in v2.8.0

type Range = pkgbytes.Range

type Ranges added in v2.8.0

type Ranges = pkgbytes.Ranges

func Diff

func Diff(
	memRanges pkgbytes.Ranges,
	memMapper types.AddressMapper,
	firmwareGood, firmwareBad *biosimage.BIOSImage,
	ignoreByteSet []byte,
) (Ranges, error)

Diff compares firmwareGoodData and firmwareBadData in areas specified by rangesOrig and returns the (memory) ranges where the data differs.

ignoreByteSet is a set of bytes, each of which is just skipped while looking for differences.

type RelatedMeasurement

type RelatedMeasurement struct {
	RelatedDataChunks DataChunks
	Measurement
}

RelatedMeasurement contains the related measurement and the data chunks specifically related to the diff.

type RelatedMeasurementsLaconic

type RelatedMeasurementsLaconic []RelatedMeasurement

RelatedMeasurementsLaconic is a helper to print measurements in a laconic way

func (RelatedMeasurementsLaconic) String

String implements fmt.Stringer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL