Documentation
¶
Overview ¶
Package compliance defines the Compliance Framework Mapping domain types.
Index ¶
- Variables
- type Assessment
- func (a *Assessment) AssessedAt() *time.Time
- func (a *Assessment) AssessedBy() *shared.ID
- func (a *Assessment) ControlID() shared.ID
- func (a *Assessment) CreatedAt() time.Time
- func (a *Assessment) DueDate() *time.Time
- func (a *Assessment) EvidenceCount() int
- func (a *Assessment) EvidenceIDs() []string
- func (a *Assessment) EvidenceType() EvidenceType
- func (a *Assessment) FindingCount() int
- func (a *Assessment) FrameworkID() shared.ID
- func (a *Assessment) ID() shared.ID
- func (a *Assessment) Notes() string
- func (a *Assessment) Owner() string
- func (a *Assessment) Priority() Priority
- func (a *Assessment) SetDueDate(dueDate *time.Time)
- func (a *Assessment) SetOwner(owner string)
- func (a *Assessment) SetPriority(priority Priority)
- func (a *Assessment) Status() ControlStatus
- func (a *Assessment) TenantID() shared.ID
- func (a *Assessment) UpdateStatus(status ControlStatus, notes string, assessedBy shared.ID)
- func (a *Assessment) UpdatedAt() time.Time
- type AssessmentFilter
- type AssessmentRepository
- type Control
- func (c *Control) Category() string
- func (c *Control) ControlID() string
- func (c *Control) CreatedAt() time.Time
- func (c *Control) Description() string
- func (c *Control) FrameworkID() shared.ID
- func (c *Control) ID() shared.ID
- func (c *Control) Metadata() map[string]any
- func (c *Control) ParentControlID() *shared.ID
- func (c *Control) SortOrder() int
- func (c *Control) Title() string
- type ControlFilter
- type ControlRepository
- type ControlStatus
- type EvidenceType
- type FindingControlMapping
- func (m *FindingControlMapping) ControlID() shared.ID
- func (m *FindingControlMapping) CreatedAt() time.Time
- func (m *FindingControlMapping) CreatedBy() *shared.ID
- func (m *FindingControlMapping) FindingID() shared.ID
- func (m *FindingControlMapping) ID() shared.ID
- func (m *FindingControlMapping) Impact() ImpactType
- func (m *FindingControlMapping) Notes() string
- func (m *FindingControlMapping) TenantID() shared.ID
- type Framework
- func (f *Framework) Category() FrameworkCategory
- func (f *Framework) CreatedAt() time.Time
- func (f *Framework) Description() string
- func (f *Framework) ID() shared.ID
- func (f *Framework) IsActive() bool
- func (f *Framework) IsSystem() bool
- func (f *Framework) Metadata() map[string]any
- func (f *Framework) Name() string
- func (f *Framework) Slug() string
- func (f *Framework) TenantID() *shared.ID
- func (f *Framework) TotalControls() int
- func (f *Framework) UpdatedAt() time.Time
- func (f *Framework) Version() string
- type FrameworkCategory
- type FrameworkFilter
- type FrameworkRepository
- type FrameworkStats
- type ImpactType
- type MappingRepository
- type Priority
Constants ¶
This section is empty.
Variables ¶
var ( ErrFrameworkNotFound = fmt.Errorf("%w: framework not found", shared.ErrNotFound) ErrControlNotFound = fmt.Errorf("%w: control not found", shared.ErrNotFound) ErrAssessmentNotFound = fmt.Errorf("%w: assessment not found", shared.ErrNotFound) ErrMappingNotFound = fmt.Errorf("%w: mapping not found", shared.ErrNotFound) ErrSystemFrameworkReadOnly = fmt.Errorf("%w: system frameworks cannot be modified", shared.ErrForbidden) ErrMappingAlreadyExists = fmt.Errorf("%w: finding is already mapped to this control", shared.ErrConflict) )
Functions ¶
This section is empty.
Types ¶
type Assessment ¶
type Assessment struct {
// contains filtered or unexported fields
}
Assessment represents a tenant's assessment of a compliance control.
func ReconstituteAssessment ¶
func ReconstituteAssessment( id, tenantID, frameworkID, controlID shared.ID, status ControlStatus, priority Priority, owner, notes string, evidenceType EvidenceType, evidenceIDs []string, evidenceCount, findingCount int, assessedBy *shared.ID, assessedAt, dueDate *time.Time, createdAt, updatedAt time.Time, ) *Assessment
ReconstituteAssessment creates an Assessment from persisted data.
func (*Assessment) AssessedAt ¶
func (a *Assessment) AssessedAt() *time.Time
func (*Assessment) AssessedBy ¶
func (a *Assessment) AssessedBy() *shared.ID
func (*Assessment) ControlID ¶
func (a *Assessment) ControlID() shared.ID
func (*Assessment) CreatedAt ¶
func (a *Assessment) CreatedAt() time.Time
func (*Assessment) DueDate ¶
func (a *Assessment) DueDate() *time.Time
func (*Assessment) EvidenceCount ¶
func (a *Assessment) EvidenceCount() int
func (*Assessment) EvidenceIDs ¶
func (a *Assessment) EvidenceIDs() []string
func (*Assessment) EvidenceType ¶
func (a *Assessment) EvidenceType() EvidenceType
func (*Assessment) FindingCount ¶
func (a *Assessment) FindingCount() int
func (*Assessment) FrameworkID ¶
func (a *Assessment) FrameworkID() shared.ID
func (*Assessment) Notes ¶
func (a *Assessment) Notes() string
func (*Assessment) Owner ¶
func (a *Assessment) Owner() string
func (*Assessment) Priority ¶
func (a *Assessment) Priority() Priority
func (*Assessment) SetDueDate ¶
func (a *Assessment) SetDueDate(dueDate *time.Time)
SetDueDate sets assessment due date.
func (*Assessment) SetOwner ¶
func (a *Assessment) SetOwner(owner string)
SetOwner sets assessment owner.
func (*Assessment) SetPriority ¶
func (a *Assessment) SetPriority(priority Priority)
SetPriority sets assessment priority.
func (*Assessment) Status ¶
func (a *Assessment) Status() ControlStatus
func (*Assessment) TenantID ¶
func (a *Assessment) TenantID() shared.ID
func (*Assessment) UpdateStatus ¶
func (a *Assessment) UpdateStatus(status ControlStatus, notes string, assessedBy shared.ID)
UpdateStatus updates the assessment status.
func (*Assessment) UpdatedAt ¶
func (a *Assessment) UpdatedAt() time.Time
type AssessmentFilter ¶
type AssessmentFilter struct {
TenantID *shared.ID
FrameworkID *shared.ID
Status *ControlStatus
Priority *Priority
}
AssessmentFilter defines criteria for filtering assessments.
type AssessmentRepository ¶
type AssessmentRepository interface {
GetByTenantAndControl(ctx context.Context, tenantID, controlID shared.ID) (*Assessment, error)
Upsert(ctx context.Context, assessment *Assessment) error
ListByFramework(ctx context.Context, tenantID, frameworkID shared.ID, page pagination.Pagination) (pagination.Result[*Assessment], error)
GetStatsByFramework(ctx context.Context, tenantID, frameworkID shared.ID) (*FrameworkStats, error)
GetOverdueCount(ctx context.Context, tenantID shared.ID) (int64, error)
}
AssessmentRepository defines the interface for assessment persistence.
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control represents an individual requirement within a compliance framework.
func ReconstituteControl ¶
func ReconstituteControl( id, frameworkID shared.ID, controlID, title, description, category string, parentControlID *shared.ID, sortOrder int, metadata map[string]any, createdAt time.Time, ) *Control
ReconstituteControl creates a Control from persisted data.
func (*Control) Description ¶
func (*Control) FrameworkID ¶
func (*Control) ParentControlID ¶
type ControlFilter ¶
type ControlFilter struct {
FrameworkID *shared.ID
Category *string
ParentOnly bool // Only top-level controls (parent_control_id IS NULL)
}
ControlFilter defines criteria for filtering controls.
type ControlRepository ¶
type ControlRepository interface {
Create(ctx context.Context, control *Control) error
GetByID(ctx context.Context, id shared.ID) (*Control, error)
ListByFramework(ctx context.Context, frameworkID shared.ID, page pagination.Pagination) (pagination.Result[*Control], error)
CountByFramework(ctx context.Context, frameworkID shared.ID) (int64, error)
}
ControlRepository defines the interface for control persistence.
type ControlStatus ¶
type ControlStatus string
ControlStatus represents the assessment status of a control.
const ( ControlStatusNotAssessed ControlStatus = "not_assessed" ControlStatusImplemented ControlStatus = "implemented" ControlStatusPartial ControlStatus = "partial" ControlStatusNotImplemented ControlStatus = "not_implemented" ControlStatusNotApplicable ControlStatus = "not_applicable" )
func ParseControlStatus ¶
func ParseControlStatus(s string) (ControlStatus, error)
ParseControlStatus parses a string to ControlStatus.
type EvidenceType ¶
type EvidenceType string
EvidenceType represents the type of evidence for an assessment.
const ( EvidenceFinding EvidenceType = "finding" EvidenceDocument EvidenceType = "document" EvidenceConfiguration EvidenceType = "configuration" EvidenceAttestation EvidenceType = "attestation" )
type FindingControlMapping ¶
type FindingControlMapping struct {
// contains filtered or unexported fields
}
FindingControlMapping represents a link between a finding and a compliance control.
func NewFindingControlMapping ¶
func NewFindingControlMapping(tenantID, findingID, controlID shared.ID, impact ImpactType) *FindingControlMapping
NewFindingControlMapping creates a new mapping.
func ReconstituteFindingControlMapping ¶
func ReconstituteFindingControlMapping( id, tenantID, findingID, controlID shared.ID, impact ImpactType, notes string, createdAt time.Time, createdBy *shared.ID, ) *FindingControlMapping
ReconstituteFindingControlMapping creates a mapping from persisted data.
func (*FindingControlMapping) ControlID ¶
func (m *FindingControlMapping) ControlID() shared.ID
func (*FindingControlMapping) CreatedAt ¶
func (m *FindingControlMapping) CreatedAt() time.Time
func (*FindingControlMapping) CreatedBy ¶
func (m *FindingControlMapping) CreatedBy() *shared.ID
func (*FindingControlMapping) FindingID ¶
func (m *FindingControlMapping) FindingID() shared.ID
func (*FindingControlMapping) Impact ¶
func (m *FindingControlMapping) Impact() ImpactType
func (*FindingControlMapping) Notes ¶
func (m *FindingControlMapping) Notes() string
func (*FindingControlMapping) TenantID ¶
func (m *FindingControlMapping) TenantID() shared.ID
type Framework ¶
type Framework struct {
// contains filtered or unexported fields
}
Framework represents a compliance framework (e.g., SOC2, ISO27001).
func NewFramework ¶
func NewFramework(tenantID shared.ID, name, slug, version, description string, category FrameworkCategory) (*Framework, error)
NewFramework creates a new custom framework.
func ReconstituteFramework ¶
func ReconstituteFramework( id shared.ID, tenantID *shared.ID, name, slug, version, description string, category FrameworkCategory, totalControls int, isSystem, isActive bool, metadata map[string]any, createdAt, updatedAt time.Time, ) *Framework
ReconstituteFramework creates a Framework from persisted data.
func (*Framework) Category ¶
func (f *Framework) Category() FrameworkCategory
func (*Framework) Description ¶
func (*Framework) TotalControls ¶
type FrameworkCategory ¶
type FrameworkCategory string
FrameworkCategory represents the category of a compliance framework.
const ( FrameworkCategoryRegulatory FrameworkCategory = "regulatory" FrameworkCategoryIndustry FrameworkCategory = "industry" FrameworkCategoryInternal FrameworkCategory = "internal" FrameworkCategoryBestPractice FrameworkCategory = "best_practice" )
type FrameworkFilter ¶
type FrameworkFilter struct {
TenantID *shared.ID
Category *FrameworkCategory
IsSystem *bool
IsActive *bool
Search *string
}
FrameworkFilter defines criteria for filtering frameworks.
type FrameworkRepository ¶
type FrameworkRepository interface {
Create(ctx context.Context, framework *Framework) error
GetByID(ctx context.Context, tenantID, id shared.ID) (*Framework, error)
GetBySlug(ctx context.Context, slug string) (*Framework, error)
Update(ctx context.Context, tenantID shared.ID, framework *Framework) error
Delete(ctx context.Context, tenantID, id shared.ID) error
List(ctx context.Context, filter FrameworkFilter, page pagination.Pagination) (pagination.Result[*Framework], error)
}
FrameworkRepository defines the interface for framework persistence.
type FrameworkStats ¶
type FrameworkStats struct {
TotalControls int64
Implemented int64
Partial int64
NotImplemented int64
NotApplicable int64
NotAssessed int64
}
FrameworkStats holds aggregated compliance statistics for a framework.
func (*FrameworkStats) ComplianceScore ¶
func (s *FrameworkStats) ComplianceScore() float64
ComplianceScore calculates the compliance percentage.
type ImpactType ¶
type ImpactType string
ImpactType represents the impact type of a finding-to-control mapping.
const ( ImpactDirect ImpactType = "direct" ImpactIndirect ImpactType = "indirect" ImpactInformational ImpactType = "informational" )
type MappingRepository ¶
type MappingRepository interface {
Create(ctx context.Context, mapping *FindingControlMapping) error
Delete(ctx context.Context, tenantID, id shared.ID) error
ListByFinding(ctx context.Context, tenantID, findingID shared.ID) ([]*FindingControlMapping, error)
ListByControl(ctx context.Context, tenantID, controlID shared.ID) ([]*FindingControlMapping, error)
}
MappingRepository defines the interface for finding-to-control mapping persistence.
type Priority ¶
type Priority string
Priority represents the priority of a control assessment.
func ParsePriority ¶
ParsePriority parses a string to Priority.