Documentation
¶
Overview ¶
Package simulation provides domain models for Breach and Attack Simulation (BAS).
Index ¶
- type ControlTest
- func (c *ControlTest) Category() string
- func (c *ControlTest) ControlID() string
- func (c *ControlTest) ControlName() string
- func (c *ControlTest) CreatedAt() time.Time
- func (c *ControlTest) Description() string
- func (c *ControlTest) Evidence() string
- func (c *ControlTest) ExpectedResult() string
- func (c *ControlTest) Framework() string
- func (c *ControlTest) ID() shared.ID
- func (c *ControlTest) LastTestedAt() *time.Time
- func (c *ControlTest) LastTestedBy() *shared.ID
- func (c *ControlTest) LinkSimulation(simulationID string)
- func (c *ControlTest) LinkedSimulationIDs() []string
- func (c *ControlTest) Name() string
- func (c *ControlTest) Notes() string
- func (c *ControlTest) RecordResult(status ControlTestStatus, evidence, notes string, testedBy shared.ID)
- func (c *ControlTest) RiskLevel() string
- func (c *ControlTest) SetTestDetails(procedure, expected string)
- func (c *ControlTest) Status() ControlTestStatus
- func (c *ControlTest) Tags() []string
- func (c *ControlTest) TenantID() shared.ID
- func (c *ControlTest) TestProcedure() string
- func (c *ControlTest) Update(name, description, controlName, category string)
- func (c *ControlTest) UpdatedAt() time.Time
- type ControlTestFilter
- type ControlTestRepository
- type ControlTestStatus
- type FrameworkStats
- type RunFilter
- type RunRepository
- type RunResult
- type RunStatus
- type Simulation
- func (s *Simulation) Activate() error
- func (s *Simulation) Config() map[string]any
- func (s *Simulation) CreatedAt() time.Time
- func (s *Simulation) CreatedBy() *shared.ID
- func (s *Simulation) Description() string
- func (s *Simulation) DetectionRate() float64
- func (s *Simulation) ID() shared.ID
- func (s *Simulation) LastResult() string
- func (s *Simulation) LastRunAt() *time.Time
- func (s *Simulation) MitreTactic() string
- func (s *Simulation) MitreTechniqueID() string
- func (s *Simulation) MitreTechniqueName() string
- func (s *Simulation) Name() string
- func (s *Simulation) NextRunAt() *time.Time
- func (s *Simulation) PreventionRate() float64
- func (s *Simulation) RecordRun(result string, detectionRate, preventionRate float64)
- func (s *Simulation) ScheduleCron() string
- func (s *Simulation) SetConfig(config map[string]any, targetAssets, tags []string) error
- func (s *Simulation) SetCreatedBy(userID shared.ID)
- func (s *Simulation) SetMITRE(tactic, techniqueID, techniqueName string)
- func (s *Simulation) SetSchedule(cron string)
- func (s *Simulation) SimulationType() SimulationType
- func (s *Simulation) Status() SimulationStatus
- func (s *Simulation) Tags() []string
- func (s *Simulation) TargetAssets() []string
- func (s *Simulation) TenantID() shared.ID
- func (s *Simulation) TotalRuns() int
- func (s *Simulation) Update(name, description string)
- func (s *Simulation) UpdatedAt() time.Time
- type SimulationFilter
- type SimulationRepository
- type SimulationRun
- func (r *SimulationRun) Complete(result RunResult, detection, prevention string, output map[string]any)
- func (r *SimulationRun) CompletedAt() *time.Time
- func (r *SimulationRun) CreatedAt() time.Time
- func (r *SimulationRun) DetectionResult() string
- func (r *SimulationRun) DurationMs() int
- func (r *SimulationRun) ErrorMessage() string
- func (r *SimulationRun) Fail(errMsg string)
- func (r *SimulationRun) ID() shared.ID
- func (r *SimulationRun) Output() map[string]any
- func (r *SimulationRun) PreventionResult() string
- func (r *SimulationRun) Result() RunResult
- func (r *SimulationRun) SetTriggeredBy(userID shared.ID)
- func (r *SimulationRun) SimulationID() shared.ID
- func (r *SimulationRun) Start()
- func (r *SimulationRun) StartedAt() *time.Time
- func (r *SimulationRun) Status() RunStatus
- func (r *SimulationRun) Steps() []map[string]any
- func (r *SimulationRun) TenantID() shared.ID
- func (r *SimulationRun) TriggeredBy() *shared.ID
- type SimulationStatus
- type SimulationType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControlTest ¶
type ControlTest struct {
// contains filtered or unexported fields
}
ControlTest represents a security control effectiveness test.
func NewControlTest ¶
func NewControlTest(tenantID shared.ID, name, framework, controlID string) (*ControlTest, error)
NewControlTest creates a new control test.
func ReconstituteControlTest ¶
func ReconstituteControlTest( id, tenantID shared.ID, name, description, framework, controlID, controlName, category string, testProcedure, expectedResult string, status ControlTestStatus, lastTestedAt *time.Time, lastTestedBy *shared.ID, evidence, notes, riskLevel string, linkedSimulationIDs, tags []string, createdAt, updatedAt time.Time, ) *ControlTest
ReconstituteControlTest creates from persisted data.
func (*ControlTest) Category ¶
func (c *ControlTest) Category() string
func (*ControlTest) ControlID ¶
func (c *ControlTest) ControlID() string
func (*ControlTest) ControlName ¶
func (c *ControlTest) ControlName() string
func (*ControlTest) CreatedAt ¶
func (c *ControlTest) CreatedAt() time.Time
func (*ControlTest) Description ¶
func (c *ControlTest) Description() string
func (*ControlTest) Evidence ¶
func (c *ControlTest) Evidence() string
func (*ControlTest) ExpectedResult ¶
func (c *ControlTest) ExpectedResult() string
func (*ControlTest) Framework ¶
func (c *ControlTest) Framework() string
func (*ControlTest) LastTestedAt ¶
func (c *ControlTest) LastTestedAt() *time.Time
func (*ControlTest) LastTestedBy ¶
func (c *ControlTest) LastTestedBy() *shared.ID
func (*ControlTest) LinkSimulation ¶
func (c *ControlTest) LinkSimulation(simulationID string)
LinkSimulation links a simulation to this control test.
func (*ControlTest) LinkedSimulationIDs ¶
func (c *ControlTest) LinkedSimulationIDs() []string
func (*ControlTest) Name ¶
func (c *ControlTest) Name() string
func (*ControlTest) Notes ¶
func (c *ControlTest) Notes() string
func (*ControlTest) RecordResult ¶
func (c *ControlTest) RecordResult(status ControlTestStatus, evidence, notes string, testedBy shared.ID)
RecordResult records a test result.
func (*ControlTest) RiskLevel ¶
func (c *ControlTest) RiskLevel() string
func (*ControlTest) SetTestDetails ¶
func (c *ControlTest) SetTestDetails(procedure, expected string)
SetTestDetails sets test procedure and expected result.
func (*ControlTest) Status ¶
func (c *ControlTest) Status() ControlTestStatus
func (*ControlTest) Tags ¶
func (c *ControlTest) Tags() []string
func (*ControlTest) TenantID ¶
func (c *ControlTest) TenantID() shared.ID
func (*ControlTest) TestProcedure ¶
func (c *ControlTest) TestProcedure() string
func (*ControlTest) Update ¶
func (c *ControlTest) Update(name, description, controlName, category string)
Update sets mutable fields.
func (*ControlTest) UpdatedAt ¶
func (c *ControlTest) UpdatedAt() time.Time
type ControlTestFilter ¶
type ControlTestFilter struct {
TenantID *shared.ID
Framework *string
Status *string
Search *string
}
ControlTestFilter defines criteria for filtering control tests.
type ControlTestRepository ¶
type ControlTestRepository interface {
Create(ctx context.Context, ct *ControlTest) error
GetByID(ctx context.Context, tenantID, id shared.ID) (*ControlTest, error)
Update(ctx context.Context, ct *ControlTest) error
Delete(ctx context.Context, tenantID, id shared.ID) error
List(ctx context.Context, filter ControlTestFilter, page pagination.Pagination) (pagination.Result[*ControlTest], error)
GetStatsByFramework(ctx context.Context, tenantID shared.ID) ([]FrameworkStats, error)
}
ControlTestRepository defines persistence for control tests.
type ControlTestStatus ¶
type ControlTestStatus string
ControlTestStatus defines the test result status.
const ( ControlTestStatusUntested ControlTestStatus = "untested" ControlTestStatusPass ControlTestStatus = "pass" ControlTestStatusFail ControlTestStatus = "fail" ControlTestStatusPartial ControlTestStatus = "partial" ControlTestStatusNotApplicable ControlTestStatus = "not_applicable" )
type FrameworkStats ¶
type FrameworkStats struct {
Framework string `json:"framework"`
Total int64 `json:"total"`
Passed int64 `json:"passed"`
Failed int64 `json:"failed"`
Partial int64 `json:"partial"`
Untested int64 `json:"untested"`
NotApplicable int64 `json:"not_applicable"`
}
FrameworkStats holds aggregated control test statistics per framework.
type RunRepository ¶
type RunRepository interface {
Create(ctx context.Context, run *SimulationRun) error
GetByID(ctx context.Context, tenantID, id shared.ID) (*SimulationRun, error)
Update(ctx context.Context, run *SimulationRun) error
List(ctx context.Context, filter RunFilter, page pagination.Pagination) (pagination.Result[*SimulationRun], error)
}
RunRepository defines persistence for simulation runs.
type Simulation ¶
type Simulation struct {
// contains filtered or unexported fields
}
Simulation represents an attack simulation definition.
func NewSimulation ¶
func NewSimulation(tenantID shared.ID, name string, simType SimulationType) (*Simulation, error)
NewSimulation creates a new simulation.
func ReconstituteSimulation ¶
func ReconstituteSimulation( id, tenantID shared.ID, name, description string, simType SimulationType, status SimulationStatus, mitreTactic, mitreTechniqueID, mitreTechniqueName string, targetAssets []string, config map[string]any, scheduleCron string, lastRunAt, nextRunAt *time.Time, totalRuns int, lastResult string, detectionRate, preventionRate float64, tags []string, createdBy *shared.ID, createdAt, updatedAt time.Time, ) *Simulation
ReconstituteSimulation creates a Simulation from persisted data.
func (*Simulation) Activate ¶
func (s *Simulation) Activate() error
Activate transitions simulation to active.
func (*Simulation) Config ¶
func (s *Simulation) Config() map[string]any
func (*Simulation) CreatedAt ¶
func (s *Simulation) CreatedAt() time.Time
func (*Simulation) CreatedBy ¶
func (s *Simulation) CreatedBy() *shared.ID
func (*Simulation) Description ¶
func (s *Simulation) Description() string
func (*Simulation) DetectionRate ¶
func (s *Simulation) DetectionRate() float64
func (*Simulation) LastResult ¶
func (s *Simulation) LastResult() string
func (*Simulation) LastRunAt ¶
func (s *Simulation) LastRunAt() *time.Time
func (*Simulation) MitreTactic ¶
func (s *Simulation) MitreTactic() string
func (*Simulation) MitreTechniqueID ¶
func (s *Simulation) MitreTechniqueID() string
func (*Simulation) MitreTechniqueName ¶
func (s *Simulation) MitreTechniqueName() string
func (*Simulation) Name ¶
func (s *Simulation) Name() string
func (*Simulation) NextRunAt ¶
func (s *Simulation) NextRunAt() *time.Time
func (*Simulation) PreventionRate ¶
func (s *Simulation) PreventionRate() float64
func (*Simulation) RecordRun ¶
func (s *Simulation) RecordRun(result string, detectionRate, preventionRate float64)
RecordRun updates run statistics after a simulation run completes.
func (*Simulation) ScheduleCron ¶
func (s *Simulation) ScheduleCron() string
func (*Simulation) SetConfig ¶
func (s *Simulation) SetConfig(config map[string]any, targetAssets, tags []string) error
SetConfig sets simulation configuration after validating allowed keys.
func (*Simulation) SetCreatedBy ¶
func (s *Simulation) SetCreatedBy(userID shared.ID)
SetCreatedBy sets the creator.
func (*Simulation) SetMITRE ¶
func (s *Simulation) SetMITRE(tactic, techniqueID, techniqueName string)
SetMITRE sets ATT&CK mapping.
func (*Simulation) SetSchedule ¶
func (s *Simulation) SetSchedule(cron string)
SetSchedule sets cron schedule.
func (*Simulation) SimulationType ¶
func (s *Simulation) SimulationType() SimulationType
func (*Simulation) Status ¶
func (s *Simulation) Status() SimulationStatus
func (*Simulation) Tags ¶
func (s *Simulation) Tags() []string
func (*Simulation) TargetAssets ¶
func (s *Simulation) TargetAssets() []string
func (*Simulation) TenantID ¶
func (s *Simulation) TenantID() shared.ID
func (*Simulation) TotalRuns ¶
func (s *Simulation) TotalRuns() int
func (*Simulation) Update ¶
func (s *Simulation) Update(name, description string)
Update sets mutable fields.
func (*Simulation) UpdatedAt ¶
func (s *Simulation) UpdatedAt() time.Time
type SimulationFilter ¶
type SimulationFilter struct {
TenantID *shared.ID
SimulationType *SimulationType
Status *SimulationStatus
Search *string
}
SimulationFilter defines criteria for filtering simulations.
type SimulationRepository ¶
type SimulationRepository interface {
Create(ctx context.Context, sim *Simulation) error
GetByID(ctx context.Context, tenantID, id shared.ID) (*Simulation, error)
Update(ctx context.Context, sim *Simulation) error
Delete(ctx context.Context, tenantID, id shared.ID) error
List(ctx context.Context, filter SimulationFilter, page pagination.Pagination) (pagination.Result[*Simulation], error)
}
SimulationRepository defines persistence for simulations.
type SimulationRun ¶
type SimulationRun struct {
// contains filtered or unexported fields
}
SimulationRun represents a single execution of a simulation.
func NewSimulationRun ¶
func NewSimulationRun(tenantID, simulationID shared.ID) *SimulationRun
NewSimulationRun creates a new run for a simulation.
func ReconstituteRun ¶
func ReconstituteRun( id, tenantID, simulationID shared.ID, status RunStatus, result RunResult, detectionResult, preventionResult string, steps []map[string]any, output map[string]any, errorMessage string, startedAt, completedAt *time.Time, durationMs int, triggeredBy *shared.ID, createdAt time.Time, ) *SimulationRun
ReconstituteRun creates a run from persisted data.
func (*SimulationRun) Complete ¶
func (r *SimulationRun) Complete(result RunResult, detection, prevention string, output map[string]any)
Complete marks the run as completed with results.
func (*SimulationRun) CompletedAt ¶
func (r *SimulationRun) CompletedAt() *time.Time
func (*SimulationRun) CreatedAt ¶
func (r *SimulationRun) CreatedAt() time.Time
func (*SimulationRun) DetectionResult ¶
func (r *SimulationRun) DetectionResult() string
func (*SimulationRun) DurationMs ¶
func (r *SimulationRun) DurationMs() int
func (*SimulationRun) ErrorMessage ¶
func (r *SimulationRun) ErrorMessage() string
func (*SimulationRun) Fail ¶
func (r *SimulationRun) Fail(errMsg string)
Fail marks the run as failed.
func (*SimulationRun) Output ¶
func (r *SimulationRun) Output() map[string]any
func (*SimulationRun) PreventionResult ¶
func (r *SimulationRun) PreventionResult() string
func (*SimulationRun) Result ¶
func (r *SimulationRun) Result() RunResult
func (*SimulationRun) SetTriggeredBy ¶
func (r *SimulationRun) SetTriggeredBy(userID shared.ID)
SetTriggeredBy sets who triggered the run.
func (*SimulationRun) SimulationID ¶
func (r *SimulationRun) SimulationID() shared.ID
func (*SimulationRun) StartedAt ¶
func (r *SimulationRun) StartedAt() *time.Time
func (*SimulationRun) Status ¶
func (r *SimulationRun) Status() RunStatus
func (*SimulationRun) Steps ¶
func (r *SimulationRun) Steps() []map[string]any
func (*SimulationRun) TenantID ¶
func (r *SimulationRun) TenantID() shared.ID
func (*SimulationRun) TriggeredBy ¶
func (r *SimulationRun) TriggeredBy() *shared.ID
type SimulationStatus ¶
type SimulationStatus string
SimulationStatus defines lifecycle states.
const ( SimulationStatusDraft SimulationStatus = "draft" SimulationStatusActive SimulationStatus = "active" SimulationStatusPaused SimulationStatus = "paused" SimulationStatusCompleted SimulationStatus = "completed" SimulationStatusArchived SimulationStatus = "archived" )
type SimulationType ¶
type SimulationType string
SimulationType defines the kind of simulation.
const ( SimulationTypeAtomic SimulationType = "atomic" SimulationTypeCampaign SimulationType = "campaign" SimulationTypeControlTest SimulationType = "control_test" )