Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine implements the PolicyEngine interface using CEL expressions
func NewEngine ¶
func NewEngine(logger *slog.Logger, config PolicyConfig) (*Engine, error)
NewEngine creates a new policy engine with a CEL-based policy
func (*Engine) Evaluate ¶
func (e *Engine) Evaluate(ctx context.Context, imageRef string, result *scanner.ScanResult, tolerations []types.CVEToleration) (*PolicyDecision, error)
Evaluate determines if an image passes security policy using CEL expression
func (*Engine) SetExpiryWarningWindow ¶
SetExpiryWarningWindow sets the duration before expiry to trigger warnings
type ExpiringToleration ¶
ExpiringToleration represents a toleration that is expiring soon
type PolicyConfig ¶
type PolicyConfig struct {
// Expression is the CEL expression that must evaluate to true for the policy to pass
// Available variables:
// - vulnerabilities: list of enriched vulnerabilities with fields:
// id, severity, packageName, version, fixedVersion, description, tolerated, tolerationStatement, tolerationExpiry
// - imageRef: string reference to the image
// - criticalCount: number of critical vulnerabilities (not tolerated)
// - highCount: number of high vulnerabilities (not tolerated)
// - mediumCount: number of medium vulnerabilities (not tolerated)
// - toleratedCount: number of tolerated vulnerabilities
Expression string `yaml:"expression" json:"expression"`
// FailureMessage is the message to return when the policy fails (optional)
FailureMessage string `yaml:"failureMessage" json:"failureMessage"`
}
PolicyConfig defines a CEL-based policy configuration
type PolicyDecision ¶
type PolicyDecision struct {
Passed bool
Reason string
ShouldSign bool
ShouldAttest bool
CriticalVulnCount int
ToleratedVulnCount int
UnfixedVulnCount int
ToleratedCVEs []string
ExpiringTolerations []ExpiringToleration
}
PolicyDecision represents the result of policy evaluation
type PolicyEngine ¶
type PolicyEngine interface {
// Evaluate determines if an image passes security policy
// Applies CVE tolerations from regsync config for the target repository
Evaluate(ctx context.Context, imageRef string, result *scanner.ScanResult, tolerations []types.CVEToleration) (*PolicyDecision, error)
}
PolicyEngine defines the interface for policy evaluation
Click to show internal directories.
Click to hide internal directories.