diff

package
v2.7.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(rangesOrig pkgbytes.Ranges, firmwareGoodData, firmwareBadData, ignoreByteSet []byte) pkgbytes.Ranges

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

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

Types

type AnalysisReport

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

	// 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(
	diffRangesOrig pkgbytes.Ranges,
	measurements pcr.Measurements,
	goodFirmware Firmware,
	badData []byte,
) (report AnalysisReport)

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 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 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 RelatedMeasurement

type RelatedMeasurement struct {
	RelatedDataChunks pcr.DataChunks
	pcr.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