Documentation
¶
Overview ¶
Package capabilities defines domain types for capability management.
Package capabilities defines domain types for capability management.
Package capabilities defines domain types for capability management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchEnvironmentPattern ¶
MatchEnvironmentPattern checks if an environment variable key matches a capability pattern. Supports exact match ("AWS_REGION"), prefix match ("AWS_*"), and wildcard ("*"). This is the canonical implementation used by both capability enforcement and plugin injection.
Examples:
- MatchEnvironmentPattern("AWS_REGION", "AWS_REGION") -> true (exact)
- MatchEnvironmentPattern("AWS_ACCESS_KEY_ID", "AWS_*") -> true (prefix)
- MatchEnvironmentPattern("PATH", "*") -> true (wildcard)
- MatchEnvironmentPattern("GCP_PROJECT", "AWS_*") -> false (no match)
Types ¶
type Capability ¶
type Capability struct {
Kind string // fs, network, env, exec
Pattern string // e.g., "/etc/**", "80,443", "AWS_*"
}
Capability represents a permission requirement or grant. This is a pure value object in the domain.
func (Capability) Equals ¶
func (c Capability) Equals(other Capability) bool
Equals checks if two capabilities are equal (value object equality).
func (Capability) IsBroad ¶
func (c Capability) IsBroad() bool
IsBroad returns true if this capability pattern is overly permissive.
func (Capability) IsEmpty ¶
func (c Capability) IsEmpty() bool
IsEmpty returns true if this is a zero-value capability.
func (Capability) RiskDescription ¶
func (c Capability) RiskDescription() string
RiskDescription returns a human-readable explanation of the security risk. This encapsulates domain knowledge about what each capability means.
func (Capability) RiskLevel ¶
func (c Capability) RiskLevel() RiskLevel
RiskLevel returns the security risk level of this capability. This is a core business rule that determines how capabilities are presented to users.
func (Capability) String ¶
func (c Capability) String() string
String returns a human-readable representation of the capability.
type Extractor ¶
type Extractor interface {
// Extract analyzes the configuration and returns a list of required capabilities.
Extract(config map[string]interface{}) []Capability
}
Extractor is an interface for extracting capabilities from a plugin configuration. Implementations of this interface contain plugin-specific logic for determining required permissions based on the user's configuration.
type Grant ¶
type Grant []Capability
Grant represents a collection of capabilities granted to a plugin. This acts as a domain entity for managing approved permissions.
func (*Grant) Add ¶
func (g *Grant) Add(capability Capability)
Add adds a capability to the grant if it's not already present.
func (Grant) Contains ¶
func (g Grant) Contains(capability Capability) bool
Contains checks if the grant contains a specific capability.
func (Grant) ContainsAny ¶
func (g Grant) ContainsAny(caps []Capability) bool
ContainsAny checks if the grant contains any of the given capabilities.
func (*Grant) Remove ¶
func (g *Grant) Remove(capability Capability)
Remove removes a capability from the grant.
type Policy ¶
type Policy struct {
}
Policy represents an authorization policy that determines if a requested operation is allowed. This is a pure domain service.
func (*Policy) IsGranted ¶
func (p *Policy) IsGranted(request Capability, granted []Capability, cwd string) bool
IsGranted checks if a specific capability (request) is covered by any of the granted capabilities. The cwd parameter must be provided for filesystem capability checks that involve relative paths. Pass an empty string if filesystem checks are not needed or all paths are absolute.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages the registration and retrieval of capability extractors.
func NewRegistry ¶
func NewRegistry() *Registry
NewRegistry creates a new, empty capability registry.
type RiskLevel ¶
type RiskLevel int
RiskLevel represents the security risk level of a capability.
const ( // RiskLevelLow represents minimal security risk (specific, narrow permissions). RiskLevelLow RiskLevel = iota // RiskLevelMedium represents moderate security risk (network access, read-only sensitive data). RiskLevelMedium // RiskLevelHigh represents high security risk (broad permissions, arbitrary code execution). RiskLevelHigh )