Documentation
¶
Overview ¶
Package runner is the scenario execution engine: it detonates or injects, polls for the expected alerts, and optionally collects related logs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Eventually ¶ added in v0.4.0
Eventually polls fn at interval until it reports done (true), returns an error, or the deadline passes. A zero deadline means "no deadline" (poll until done or error). On deadline it returns nil — the caller inspects the state fn was mutating to decide success or failure.
Types ¶
type DiscoveredAlert ¶
type DiscoveredAlert struct {
RuleName string `json:"ruleName"`
AlertID string `json:"alertId"`
Severity string `json:"severity,omitempty"`
}
DiscoveredAlert represents an alert found during explore mode.
type ExpectationResult ¶ added in v0.4.0
ExpectationResult is the mid-run state of a single expectation. Passed is nil while the expectation is still pending (not yet matched).
type Indicators ¶
type RunResult ¶ added in v0.4.0
type RunResult struct {
RunId string `json:"runId"`
StartTime time.Time `json:"startTime"`
EndTime time.Time `json:"endTime"`
TotalScenarios int `json:"totalScenarios"`
SuccessScenarios int `json:"successScenarios"`
FailedScenarios int `json:"failedScenarios"`
Scenarios []ScenarioResult `json:"scenarios"`
}
RunResult is the aggregate outcome of a whole run (one assessment execution).
type Runner ¶
Runner executes exactly one scenario. Fan-out across multiple scenarios is the sole responsibility of the parallel executor (see internal/results).
func (*Runner) CleanupScenario ¶
func (*Runner) Run ¶
func (m *Runner) Run(scenario *Scenario) ScenarioResult
Run executes the given scenario and returns its populated result. Wall-clock timing (TimeExecuted, DurationSeconds) is filled in by the caller.
type Scenario ¶
type Scenario struct {
Name string
RunID string
EnvVars map[string]string // run-specific env vars (nil = use process env)
Detonator detonators.Detonator
Injector injectors.Injector
Collector collectors.Collector
Timeout time.Duration
Matchers []matchers.AlertGeneratedMatcher
Indicators *Indicators
Metadata *Metadata
StatusCallback func(scenarioName, phase string)
// IdentityCallback fires once after detonation, carrying executor identity.
IdentityCallback func(scenarioName string, identity ScenarioIdentity)
// ExpectationsCallback fires when an expectation newly matches, carrying the
// current pass/pending state of every expectation.
ExpectationsCallback func(scenarioName string, results []ExpectationResult)
ExploreMode bool // when true, discover all matching alerts instead of matching specific rules
CleanupAlerts bool // when true in explore mode, close discovered alerts after run
}
type ScenarioIdentity ¶ added in v0.3.0
type ScenarioIdentity struct {
ExecutorName string
ExecutorType string
ExecutionID string
SimulationID string
}
ScenarioIdentity is the executor identity surfaced mid-run, after detonation.
type ScenarioResult ¶
type ScenarioResult struct {
Name string `json:"name"`
Success bool `json:"isSuccess"`
ErrorMessage string `json:"errorMessage"`
DurationSeconds float64 `json:"durationSeconds"`
MatchingDurationSeconds float64 `json:"matchingDurationSeconds"`
TimeExecuted time.Time `json:"timeExecuted"`
ExecutorName string `json:"executorName"`
ExecutorType string `json:"executorType"`
ExecutionId string `json:"executionId"`
SimulationID string `json:"simulationId,omitempty"`
Matchers []matchers.AlertGeneratedMatcher `json:"expectations,omitempty"`
UnmetExpectations []matchers.AlertGeneratedMatcher `json:"-"`
Indicators *Indicators `json:"indicators,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
CollectedLogPath string `json:"collectedLogPath,omitempty"`
CollectedDocCount int `json:"collectedDocCount,omitempty"`
DiscoveredAlerts []DiscoveredAlert `json:"discoveredAlerts,omitempty"`
ExploreMode bool `json:"exploreMode,omitempty"`
}
ScenarioResult is the single in-memory outcome of executing one scenario, returned by the runner and consumed by the parallel executor and the web layer. The runner populates everything except the wall-clock timing (TimeExecuted, DurationSeconds), which the executor records around the call. The persistence row (db.ScenarioResult) is a separate column-shaped DTO.