Documentation
¶
Index ¶
- Variables
- func AlreadyExistsError(name string) error
- func NotFoundError(id string) error
- type Policy
- func (p *Policy) Activate()
- func (p *Policy) AssetID() *shared.ID
- func (p *Policy) CalculateDeadline(severity string, detectedAt time.Time) time.Time
- func (p *Policy) CreatedAt() time.Time
- func (p *Policy) CriticalDays() int
- func (p *Policy) Deactivate()
- func (p *Policy) Description() string
- func (p *Policy) DisableEscalation()
- func (p *Policy) EnableEscalation(config map[string]any)
- func (p *Policy) EscalationConfig() map[string]any
- func (p *Policy) EscalationEnabled() bool
- func (p *Policy) GetDaysForSeverity(severity string) int
- func (p *Policy) HighDays() int
- func (p *Policy) ID() shared.ID
- func (p *Policy) InfoDays() int
- func (p *Policy) IsActive() bool
- func (p *Policy) IsAssetSpecific() bool
- func (p *Policy) IsDefault() bool
- func (p *Policy) LowDays() int
- func (p *Policy) MediumDays() int
- func (p *Policy) Name() string
- func (p *Policy) SetAssetID(assetID shared.ID)
- func (p *Policy) SetDefault(isDefault bool)
- func (p *Policy) SetWarningThreshold(percent int) error
- func (p *Policy) TenantID() shared.ID
- func (p *Policy) UpdateDescription(description string)
- func (p *Policy) UpdateName(name string) error
- func (p *Policy) UpdateSLADays(critical, high, medium, low, info int) error
- func (p *Policy) UpdatedAt() time.Time
- func (p *Policy) WarningThresholdPct() int
- type Repository
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("SLA policy not found") ErrAlreadyExists = errors.New("SLA policy already exists") )
View Source
var DefaultSLADays = map[string]int{
"critical": 2,
"high": 15,
"medium": 30,
"low": 60,
"info": 90,
}
DefaultSLADays contains the default remediation days per severity.
Functions ¶
func AlreadyExistsError ¶
AlreadyExistsError returns a formatted already exists error.
func NotFoundError ¶
NotFoundError returns a formatted not found error.
Types ¶
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy represents an SLA policy for findings remediation.
func NewDefaultPolicy ¶
NewDefaultPolicy creates a new default SLA Policy for a tenant.
func Reconstitute ¶
func Reconstitute( id shared.ID, tenantID shared.ID, assetID *shared.ID, name string, description string, isDefault bool, criticalDays int, highDays int, mediumDays int, lowDays int, infoDays int, warningThresholdPct int, escalationEnabled bool, escalationConfig map[string]any, isActive bool, createdAt time.Time, updatedAt time.Time, ) *Policy
Reconstitute recreates a Policy from persistence.
func (*Policy) CalculateDeadline ¶
CalculateDeadline calculates the SLA deadline for a finding.
func (*Policy) CriticalDays ¶
func (*Policy) Deactivate ¶
func (p *Policy) Deactivate()
func (*Policy) Description ¶
func (*Policy) DisableEscalation ¶
func (p *Policy) DisableEscalation()
func (*Policy) EnableEscalation ¶
func (*Policy) EscalationConfig ¶
func (*Policy) EscalationEnabled ¶
func (*Policy) GetDaysForSeverity ¶
GetDaysForSeverity returns the remediation days for a given severity.
func (*Policy) IsAssetSpecific ¶
IsAssetSpecific checks if this policy is for a specific asset.
func (*Policy) MediumDays ¶
func (*Policy) SetAssetID ¶
func (*Policy) SetDefault ¶
func (*Policy) SetWarningThreshold ¶
func (*Policy) UpdateDescription ¶
func (*Policy) UpdateName ¶
func (*Policy) UpdateSLADays ¶
func (*Policy) WarningThresholdPct ¶
type Repository ¶
type Repository interface {
// Create persists a new SLA policy.
Create(ctx context.Context, policy *Policy) error
// GetByID retrieves a policy by ID.
GetByID(ctx context.Context, id shared.ID) (*Policy, error)
// GetByTenantAndID retrieves a policy by tenant and ID.
GetByTenantAndID(ctx context.Context, tenantID, id shared.ID) (*Policy, error)
// GetByAsset retrieves the policy for a specific asset.
// Returns the asset-specific policy if exists, otherwise the tenant default.
GetByAsset(ctx context.Context, tenantID, assetID shared.ID) (*Policy, error)
// GetTenantDefault retrieves the default policy for a tenant.
GetTenantDefault(ctx context.Context, tenantID shared.ID) (*Policy, error)
// Update updates an existing policy.
Update(ctx context.Context, policy *Policy) error
// Delete removes a policy.
Delete(ctx context.Context, id shared.ID) error
// ListByTenant returns all policies for a tenant.
ListByTenant(ctx context.Context, tenantID shared.ID) ([]*Policy, error)
// ExistsByAsset checks if an asset-specific policy exists.
ExistsByAsset(ctx context.Context, assetID shared.ID) (bool, error)
}
Repository defines the SLA policy repository interface.
Click to show internal directories.
Click to hide internal directories.