diff

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeDetail

type ChangeDetail struct {
	OldRecord *snapshot.FileRecord `json:"old_record"`
	NewRecord *snapshot.FileRecord `json:"new_record"`
	Changes   []string             `json:"changes"`
}

ChangeDetail represents details about a modified file

type ChangeType

type ChangeType string

ChangeType represents the type of change

const (
	ChangeAdded    ChangeType = "added"
	ChangeModified ChangeType = "modified"
	ChangeDeleted  ChangeType = "deleted"
)

type Config

type Config struct {
	IgnorePatterns []string
	Verbose        bool
	ShowHashes     bool
	OnlyChanges    bool
}

Config holds diff configuration

type CriticalChange

type CriticalChange struct {
	Record   *snapshot.FileRecord `json:"record"`
	Path     string               `json:"path"`
	Type     ChangeType           `json:"type"`
	Reason   string               `json:"reason"`
	Category string               `json:"category"`
	Severity int                  `json:"severity"` // 1-10 scale
}

CriticalChange represents a security-relevant change

type CriticalityRule

type CriticalityRule struct {
	Matcher     func(path string) bool
	Severity    map[ChangeType]int
	Name        string
	Category    string
	Description string
}

CriticalityRule defines how to detect and score critical changes

func GetCriticalityRules

func GetCriticalityRules() []CriticalityRule

GetCriticalityRules returns all hardcoded criticality rules Edit this function to add/modify/remove rules

type Differ

type Differ struct {
	// contains filtered or unexported fields
}

Differ handles comparing snapshots

func New

func New(config *Config) *Differ

New creates a new differ

func (*Differ) Compare

func (d *Differ) Compare(baseline, current *snapshot.Snapshot) *Result

Compare compares two snapshots and returns the differences

type PathIgnorer

type PathIgnorer struct {
	// contains filtered or unexported fields
}

PathIgnorer handles ignore pattern matching for diffs

func (*PathIgnorer) ShouldIgnore

func (i *PathIgnorer) ShouldIgnore(path string) bool

ShouldIgnore checks if a path should be ignored during diff

type Result

type Result struct {
	Generated time.Time                       `json:"generated"`
	Baseline  *snapshot.Snapshot              `json:"baseline"`
	Current   *snapshot.Snapshot              `json:"current"`
	Added     map[string]*snapshot.FileRecord `json:"added"`
	Modified  map[string]*ChangeDetail        `json:"modified"`
	Deleted   map[string]*snapshot.FileRecord `json:"deleted"`
	Summary   Summary                         `json:"summary"`
}

Result represents the comparison between two snapshots

func (*Result) ExportCSV

func (r *Result) ExportCSV() [][]string

ExportCSV exports the diff results to CSV format

func (*Result) FilterChanges

func (r *Result) FilterChanges(filter func(path string, changeType ChangeType) bool) *Result

FilterChanges filters the diff result based on criteria

func (*Result) GetChangesByType

func (r *Result) GetChangesByType() map[ChangeType][]string

GetChangesByType returns changes grouped by type

func (*Result) GetCriticalChanges

func (r *Result) GetCriticalChanges() []CriticalChange

GetCriticalChanges analyzes a diff result for critical changes

func (*Result) GetCriticalChangesByCategory

func (r *Result) GetCriticalChangesByCategory(category string) []CriticalChange

GetCriticalChangesByCategory returns critical changes filtered by category

func (*Result) GetCriticalChangesBySeverity

func (r *Result) GetCriticalChangesBySeverity(minSeverity int) []CriticalChange

GetCriticalChangesBySeverity returns critical changes above a minimum severity

func (*Result) GetSecurityCriticalChanges

func (r *Result) GetSecurityCriticalChanges() []CriticalChange

GetSecurityCriticalChanges returns only security-related critical changes

type Summary

type Summary struct {
	AddedCount     int           `json:"added_count"`
	ModifiedCount  int           `json:"modified_count"`
	DeletedCount   int           `json:"deleted_count"`
	TotalChanges   int           `json:"total_changes"`
	AddedSize      int64         `json:"added_size"`
	DeletedSize    int64         `json:"deleted_size"`
	SizeDiff       int64         `json:"size_diff"`
	ComparisonTime time.Duration `json:"comparison_time"`
}

Summary contains summary statistics

Jump to

Keyboard shortcuts

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