Documentation
¶
Overview ¶
Package diff provides configuration comparison functionality for OPNsense configurations.
Index ¶
- type Analyzer
- func (a *Analyzer) CompareDHCP(old, newCfg *schema.Dhcpd) []Change
- func (a *Analyzer) CompareFirewallRules(old, newCfg []schema.Rule) []Change
- func (a *Analyzer) CompareInterfaces(old, newCfg *schema.Interfaces) []Change
- func (a *Analyzer) CompareNAT(old, newCfg *schema.Nat) []Change
- func (a *Analyzer) CompareRoutes(old, newCfg *schema.StaticRoutes) []Change
- func (a *Analyzer) CompareSystem(old, newCfg *schema.System) []Change
- func (a *Analyzer) CompareUsers(old, newCfg []schema.User) []Change
- func (a *Analyzer) CompareVLANs(old, newCfg *schema.VLANs) []Change
- type Change
- type ChangeType
- type Engine
- type Metadata
- type OpnSenseDocument
- type Options
- type Result
- type Section
- type SecurityImpact
- type Summary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Analyzer ¶
type Analyzer struct{}
Analyzer performs structural comparison of configurations.
func (*Analyzer) CompareDHCP ¶
CompareDHCP compares DHCP configuration between two configs. Focuses on persistent configuration (static reservations) not ephemeral state (leases).
func (*Analyzer) CompareFirewallRules ¶
CompareFirewallRules compares firewall rules between two configs.
func (*Analyzer) CompareInterfaces ¶
func (a *Analyzer) CompareInterfaces(old, newCfg *schema.Interfaces) []Change
CompareInterfaces compares interface configuration between two configs.
func (*Analyzer) CompareNAT ¶
CompareNAT compares NAT configuration between two configs.
func (*Analyzer) CompareRoutes ¶
func (a *Analyzer) CompareRoutes(old, newCfg *schema.StaticRoutes) []Change
CompareRoutes compares static route configuration between two configs.
func (*Analyzer) CompareSystem ¶
CompareSystem compares system configuration between two configs.
func (*Analyzer) CompareUsers ¶
CompareUsers compares user configuration between two configs.
type Change ¶
type Change struct {
Type ChangeType `json:"type"`
Section Section `json:"section"`
Path string `json:"path"`
Description string `json:"description"`
OldValue string `json:"old_value,omitempty"`
NewValue string `json:"new_value,omitempty"`
SecurityImpact string `json:"security_impact,omitempty"`
}
Change represents a single configuration change.
type ChangeType ¶
type ChangeType string
ChangeType represents the type of configuration change.
const ( // ChangeAdded indicates a new element was added. ChangeAdded ChangeType = "added" // ChangeRemoved indicates an element was removed. ChangeRemoved ChangeType = "removed" // ChangeModified indicates an element was modified. ChangeModified ChangeType = "modified" )
func (ChangeType) IsValid ¶
func (c ChangeType) IsValid() bool
IsValid returns true if the change type is a valid value.
func (ChangeType) String ¶
func (c ChangeType) String() string
String returns the string representation of the change type.
func (ChangeType) Symbol ¶
func (c ChangeType) Symbol() string
Symbol returns a single-character symbol for the change type.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine orchestrates configuration comparison.
type Metadata ¶
type Metadata struct {
OldFile string `json:"old_file"`
NewFile string `json:"new_file"`
OldVersion string `json:"old_version,omitempty"`
NewVersion string `json:"new_version,omitempty"`
ComparedAt time.Time `json:"compared_at"`
ToolVersion string `json:"tool_version"`
}
Metadata contains comparison metadata.
type OpnSenseDocument ¶
type OpnSenseDocument = model.OpnSenseDocument
OpnSenseDocument is a type alias for model.OpnSenseDocument for package convenience.
type Options ¶
type Options struct {
Sections []string // Filter to specific sections (empty = all)
SecurityOnly bool // Show only security-relevant changes
Format string // Output format (terminal, markdown, json)
}
Options configures diff behavior.
func (*Options) ShouldIncludeSection ¶
ShouldIncludeSection returns true if the section should be included.
type Result ¶
type Result struct {
Summary Summary `json:"summary"`
Metadata Metadata `json:"metadata"`
Changes []Change `json:"changes"`
}
Result contains the complete diff result.
func (*Result) ChangesBySection ¶
ChangesBySection returns changes grouped by section.
func (*Result) HasChanges ¶
HasChanges returns true if there are any changes.
type Section ¶
type Section string
Section represents a configuration section.
const ( // SectionSystem represents system configuration. SectionSystem Section = "system" // SectionFirewall represents firewall rules. SectionFirewall Section = "firewall" // SectionNAT represents NAT configuration. SectionNAT Section = "nat" // SectionInterfaces represents interface configuration. SectionInterfaces Section = "interfaces" // SectionVLANs represents VLAN configuration. SectionVLANs Section = "vlans" // SectionDHCP represents DHCP configuration. SectionDHCP Section = "dhcp" // SectionDNS represents DNS configuration. SectionDNS Section = "dns" // SectionVPN represents VPN configuration. SectionVPN Section = "vpn" // SectionUsers represents user configuration. SectionUsers Section = "users" // SectionRouting represents routing configuration. SectionRouting Section = "routing" // SectionCertificates represents certificate configuration. SectionCertificates Section = "certificates" )
func ImplementedSections ¶
func ImplementedSections() []Section
ImplementedSections returns sections that have comparison logic implemented.
func (Section) IsImplemented ¶
IsImplemented returns true if the section has comparison logic implemented.
type SecurityImpact ¶
type SecurityImpact string
SecurityImpact represents the security impact level of a change.
const ( // SecurityImpactHigh indicates a high security impact (e.g., permissive any-any rules). SecurityImpactHigh SecurityImpact = "high" // SecurityImpactMedium indicates a medium security impact (e.g., user changes, NAT modifications). SecurityImpactMedium SecurityImpact = "medium" // SecurityImpactLow indicates a low security impact (e.g., minor configuration changes). SecurityImpactLow SecurityImpact = "low" )
func (SecurityImpact) IsValid ¶
func (s SecurityImpact) IsValid() bool
IsValid returns true if the security impact is a valid value.
func (SecurityImpact) String ¶
func (s SecurityImpact) String() string
String returns the string representation of the security impact.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package formatters provides output formatting for diff results.
|
Package formatters provides output formatting for diff results. |