Documentation
¶
Overview ¶
Package entities contains domain entities for the Reglet domain model.
Package entities contains domain entities for the Reglet domain model. These are pure domain types with NO infrastructure dependencies.
Package entities contains domain entities for the Reglet domain model.
Package entities contains domain entities for the Reglet domain model.
Index ¶
- type Control
- func (c *Control) GetEffectiveTimeout(defaultTimeout time.Duration) time.Duration
- func (c *Control) HasAnyTag(tags []string) bool
- func (c *Control) HasDependency(controlID string) bool
- func (c *Control) HasTag(tag string) bool
- func (c *Control) IsEmpty() bool
- func (c *Control) MatchesAnySeverity(severities []string) bool
- func (c *Control) MatchesSeverity(severity string) bool
- func (c *Control) ObservationCount() int
- func (c *Control) Validate() error
- type ControlDefaults
- type ControlsSection
- type ObservationDefinition
- type PluginRegistry
- type PluginSpec
- type Profile
- func (p *Profile) AddControl(ctrl Control) error
- func (p *Profile) ApplyDefaults()
- func (p *Profile) BuildPluginRegistry() (*PluginRegistry, error)
- func (p *Profile) CheckForCycles() error
- func (p *Profile) ControlCount() int
- func (p *Profile) ExcludeControlsByID(excludeIDs []string) []Control
- func (p *Profile) GetAllControls() []Control
- func (p *Profile) GetControl(id string) *Control
- func (p *Profile) GetMetadata() ProfileMetadata
- func (p *Profile) GetPlugins() []string
- func (p *Profile) GetVars() map[string]interface{}
- func (p *Profile) HasControl(id string) bool
- func (p *Profile) SelectControlsBySeverity(severities []string) []Control
- func (p *Profile) SelectControlsByTags(tags []string) []Control
- func (p *Profile) Validate() error
- type ProfileMetadata
- type ProfileReader
- type ValidatedProfile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Control ¶
type Control struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description,omitempty"`
Severity string `yaml:"severity,omitempty"`
Owner string `yaml:"owner,omitempty"`
Tags []string `yaml:"tags,omitempty"`
DependsOn []string `yaml:"depends_on,omitempty"`
Timeout time.Duration `yaml:"timeout,omitempty"`
ObservationDefinitions []ObservationDefinition `yaml:"observations"`
}
Control represents a specific compliance check or validation unit. It is uniquely identified by its ID.
func (*Control) GetEffectiveTimeout ¶
GetEffectiveTimeout returns the control's timeout with fallback to default.
func (*Control) HasDependency ¶
HasDependency returns true if the control depends on the specified control ID.
func (*Control) MatchesAnySeverity ¶
MatchesAnySeverity returns true if the control matches any of the severities.
func (*Control) MatchesSeverity ¶
MatchesSeverity returns true if the control matches the specified severity.
func (*Control) ObservationCount ¶
ObservationCount returns the number of observations in this control.
type ControlDefaults ¶
type ControlDefaults struct {
Severity string `yaml:"severity,omitempty"`
Owner string `yaml:"owner,omitempty"`
Tags []string `yaml:"tags,omitempty"`
Timeout time.Duration `yaml:"timeout,omitempty"`
}
ControlDefaults specifies values inherited by controls when not explicitly set.
type ControlsSection ¶
type ControlsSection struct {
Defaults *ControlDefaults `yaml:"defaults,omitempty"`
Items []Control `yaml:"items"`
}
ControlsSection groups validation controls and their default settings.
type ObservationDefinition ¶
type ObservationDefinition struct {
Plugin string `yaml:"plugin"`
Config map[string]interface{} `yaml:"config,omitempty"`
Expect []string `yaml:"expect,omitempty"`
}
ObservationDefinition configuration for a specific plugin execution. It is an immutable value object. Renamed from Observation to ObservationDefinition to avoid confusion with ObservationResult.
type PluginRegistry ¶
type PluginRegistry struct {
// contains filtered or unexported fields
}
PluginRegistry maps plugin aliases to their specifications. This allows observations to reference plugins by alias while the runtime resolves them to their actual sources.
func NewPluginRegistry ¶
func NewPluginRegistry() *PluginRegistry
NewPluginRegistry creates a new empty plugin registry.
func (*PluginRegistry) AllSpecs ¶
func (pr *PluginRegistry) AllSpecs() []*PluginSpec
AllSpecs returns all registered plugin specifications.
func (*PluginRegistry) HasPlugin ¶
func (pr *PluginRegistry) HasPlugin(name string) bool
HasPlugin reports whether a plugin with the given name is registered.
func (*PluginRegistry) Register ¶
func (pr *PluginRegistry) Register(spec *PluginSpec) error
Register adds a plugin specification to the registry.
func (*PluginRegistry) Resolve ¶
func (pr *PluginRegistry) Resolve(alias string) *PluginSpec
Resolve looks up a plugin by alias and returns its specification. If the alias is not registered, it returns a default spec where name=source.
type PluginSpec ¶
type PluginSpec struct {
// Name is the alias used in observations (e.g., "file", "file-legacy")
Name string
// Source is the plugin source (e.g., "file", "ghcr.io/reglet-dev/reglet-plugins/file:1.0.0")
Source string
// Version is the explicit version constraint (e.g., "1.2.0")
Version string
// Digest is the optional content hash for pinning (e.g., "sha256:abc123...")
Digest string
// Verify indicates whether signature verification is required
Verify bool
}
PluginSpec represents a plugin declaration with optional version and source.
func ParsePluginDeclaration ¶
func ParsePluginDeclaration(declaration string) (*PluginSpec, error)
ParsePluginDeclaration parses a single plugin declaration string. Supported formats:
- "file" -> name=file, source=file
- "file@1.2.0" -> name=file, source=file, version=1.2.0
- "ghcr.io/.../file:1.2.0" -> name=file, source=full path
- "ghcr.io/.../file@sha256:abc..." -> name=file, source=path, digest=sha256:abc...
func ParsePluginDeclarationWithAlias ¶
func ParsePluginDeclarationWithAlias(alias string, source interface{}) (*PluginSpec, error)
ParsePluginDeclarationWithAlias parses a plugin declaration with an explicit alias. Format: "alias: source" or expanded map format.
func (*PluginSpec) IsBuiltIn ¶
func (ps *PluginSpec) IsBuiltIn() bool
IsBuiltIn returns true if this plugin references a built-in plugin.
func (*PluginSpec) PluginName ¶
func (ps *PluginSpec) PluginName() string
PluginName returns the actual plugin name to load (without version suffix).
type Profile ¶
type Profile struct {
Metadata ProfileMetadata `yaml:"profile"`
Plugins []string `yaml:"plugins,omitempty"`
Vars map[string]interface{} `yaml:"vars,omitempty"`
Controls ControlsSection `yaml:"controls"`
}
Profile represents the Reglet profile configuration. Aggregate root in the Configuration context.
Profile defines the validation configuration and ruleset. It serves as the aggregate root for the configuration context.
Invariants enforced: - Unique control IDs - All dependencies must exist - Name and version are mandatory - At least one observation per control
func (*Profile) AddControl ¶
AddControl safely adds a new control to the profile. It returns an error if the control is invalid or already exists.
func (*Profile) ApplyDefaults ¶
func (p *Profile) ApplyDefaults()
ApplyDefaults propagates default values to all controls in the profile.
func (*Profile) BuildPluginRegistry ¶
func (p *Profile) BuildPluginRegistry() (*PluginRegistry, error)
BuildPluginRegistry creates a PluginRegistry from the profile's plugin declarations. This supports the current simple list format for backwards compatibility. Future versions will support map format with aliases.
func (*Profile) CheckForCycles ¶
CheckForCycles checks if the control dependency graph contains any cycles.
func (*Profile) ControlCount ¶
ControlCount returns the total number of controls.
func (*Profile) ExcludeControlsByID ¶
ExcludeControlsByID returns a subset of controls excluding the specified IDs.
func (*Profile) GetAllControls ¶
GetAllControls returns all controls in the profile.
func (*Profile) GetControl ¶
GetControl retrieves a control by its ID. It returns nil if the control is not found.
func (*Profile) GetMetadata ¶
func (p *Profile) GetMetadata() ProfileMetadata
GetMetadata returns the profile metadata.
func (*Profile) GetPlugins ¶
GetPlugins returns the list of plugins required by this profile.
func (*Profile) HasControl ¶
HasControl reports whether a control with the given ID exists.
func (*Profile) SelectControlsBySeverity ¶
SelectControlsBySeverity returns a subset of controls matching any of the specified severities. If severities is empty, all controls are returned.
func (*Profile) SelectControlsByTags ¶
SelectControlsByTags returns a subset of controls matching any of the specified tags. If tags is empty, all controls are returned.
type ProfileMetadata ¶
type ProfileMetadata struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Description string `yaml:"description,omitempty"`
}
ProfileMetadata contains descriptive information about the profile.
type ProfileReader ¶
type ProfileReader interface {
// Metadata access
GetMetadata() ProfileMetadata
GetPlugins() []string
BuildPluginRegistry() (*PluginRegistry, error)
GetVars() map[string]interface{}
// Control queries
GetControl(id string) *Control
HasControl(id string) bool
ControlCount() int
GetAllControls() []Control
// Filtering
SelectControlsByTags(tags []string) []Control
SelectControlsBySeverity(severities []string) []Control
ExcludeControlsByID(excludeIDs []string) []Control
// Validation
CheckForCycles() error
}
ProfileReader provides read-only access to profile data. This interface enforces immutability and prevents accidental mutations.
Both raw Profile and ValidatedProfile implement this interface, allowing consumers to work with either type through the same contract.
type ValidatedProfile ¶
type ValidatedProfile struct {
*Profile // Embedded raw profile (provides ProfileReader interface)
}
ValidatedProfile represents a fully compiled and validated profile. This is an immutable value object created by the ProfileCompiler.
It embeds the raw Profile and adds compiled/enriched state: - Defaults have been applied to all controls - All validations have passed - Dependency graph has been verified (no cycles)
func NewValidatedProfile ¶
func NewValidatedProfile(profile *Profile) *ValidatedProfile
NewValidatedProfile creates a new ValidatedProfile from a raw profile. This is an internal constructor - use ProfileCompiler.Compile() instead.
func (*ValidatedProfile) IsValidated ¶
func (v *ValidatedProfile) IsValidated() bool
IsValidated always returns true for ValidatedProfile. This is a marker method to distinguish from raw Profile at runtime if needed.