Documentation
¶
Index ¶
- Constants
- func Run(ctx context.Context, config RunConfig) error
- type Campaign
- type CampaignReport
- type Catalog
- type DetectionSummary
- type Expected
- type ObservationAdapter
- type ObservationEvidence
- type PhaseDetection
- type PhaseDetectionStat
- type PhaseReport
- type Request
- type RuleAction
- type RuleCampaign
- type RuleCampaignReport
- type RuleCatalog
- type RuleEvaluation
- type RulePhase
- type RulePolicy
- type RuleSuiteSummary
- type RuleSummary
- type RuleTarget
- type RunConfig
- type Summary
- type WorkloadContract
Constants ¶
const ( // RuleActionRequest sends one HTTP request from the source to a target. RuleActionRequest = "request" // RuleActionRestart restarts the source Deployment, a routine rollout. RuleActionRestart = "restart" )
Rule action kinds.
const ( SuiteMission = "mission" SuiteRules = "rules" )
Eval suites selected by RunConfig.Suite.
const ( // RuleSourcePolicy is the campaign's operator-written policy, run as an active CEL ruleset. RuleSourcePolicy = "policy" // RuleSourceAuthored is the production resource rule author's draft for the // source workload, written from its observed behavior at the end of the // baseline phase and run as an approved (active) resource rule. RuleSourceAuthored = "authored" )
Rule sources scored by the rule evals.
const ( RuleTruePositive = "true_positive" RuleFalseNegative = "false_negative" RuleTrueNegative = "true_negative" RuleFalsePositive = "false_positive" )
Rule eval outcomes.
const CatalogSchemaVersion = "agentshield.mission-evals/v1alpha1"
const RuleCatalogSchemaVersion = "agentshield.rule-evals/v1alpha1"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Campaign ¶
type Campaign struct {
ID string `json:"id"`
Class string `json:"class"`
ThreatModel string `json:"threatModel"`
CompromiseAssumption string `json:"compromiseAssumption"`
SourceComponent string `json:"sourceComponent"`
BaselineTarget string `json:"baselineTarget"`
BaselineRequest Request `json:"baselineRequest"`
ObservedTarget string `json:"observedTarget"`
ObservedRequest Request `json:"observedRequest"`
Governed bool `json:"governed"`
Expected Expected `json:"expected"`
}
type CampaignReport ¶
type CampaignReport struct {
SchemaVersion string `json:"schemaVersion"`
Campaign Campaign `json:"campaign"`
StartedAt time.Time `json:"startedAt"`
FinishedAt time.Time `json:"finishedAt"`
Phases []PhaseReport `json:"phases"`
Detection []PhaseDetection `json:"detection"`
Signals []detector.InvestigationSignal `json:"signals"`
Retrievals []reasoning.ContextResult `json:"retrievals,omitempty"`
Assessment reasoning.Assessment `json:"assessment"`
Promotion reasoning.Promotion `json:"promotion"`
Usage reasoning.Usage `json:"usage"`
ModelLatencyMillis int64 `json:"modelLatencyMillis"`
Variant string `json:"variant"`
Model string `json:"model,omitempty"`
RetrievalMode string `json:"retrievalMode,omitempty"`
DetectorOnly bool `json:"detectorOnly,omitempty"`
MatchesExpectation bool `json:"matchesExpectation"`
Error string `json:"error,omitempty"`
}
type Catalog ¶
type Catalog struct {
SchemaVersion string `json:"schemaVersion"`
Mission string `json:"mission"`
Campaigns []Campaign `json:"campaigns"`
}
func LoadCatalog ¶
type DetectionSummary ¶
type DetectionSummary struct {
// SecurityPathRecall is the share of security campaigns whose observed window has an
// investigation-eligible signal anchored to the observed path; promotion is impossible without one.
SecurityPathRecall float64 `json:"securityPathRecall"`
Phases map[string]PhaseDetectionStat `json:"phases"`
}
DetectionSummary aggregates deterministic detection across campaign phases.
type ObservationAdapter ¶
type ObservationAdapter interface {
ID() string
Manifest(Campaign, WorkloadContract) string
WaitReady(context.Context, string, WorkloadContract) error
}
type ObservationEvidence ¶
type PhaseDetection ¶
type PhaseDetection struct {
Phase string `json:"phase"`
Signals []detector.InvestigationSignal `json:"signals"`
SignalCount int `json:"signalCount"`
EligibleSignals int `json:"eligibleSignals"`
// InvokesAgent reports whether agentic investigation would run for this window.
InvokesAgent bool `json:"invokesAgent"`
// PathSignal reports an investigation-eligible signal anchored to both observed endpoints.
PathSignal bool `json:"pathSignal,omitempty"`
// Unsettled reports a setup window measured before the graph stopped changing.
Unsettled bool `json:"unsettled,omitempty"`
}
PhaseDetection records deterministic detection for one graph change window without model calls.
type PhaseDetectionStat ¶
type PhaseReport ¶
type PhaseReport struct {
Name string `json:"name"`
StartedAt time.Time `json:"startedAt"`
CheckpointSequence uint64 `json:"checkpointSequence"`
ObservationContract string `json:"observationContract"`
Observation ObservationEvidence `json:"observation"`
Incident reasoning.IncidentContext `json:"incident,omitempty"`
}
type RuleAction ¶
type RuleAction struct {
Kind string `json:"kind"`
Target string `json:"target,omitempty"`
Method string `json:"method,omitempty"`
Path string `json:"path,omitempty"`
// ExpectStatus is the HTTP status the request must receive; zero means 200.
ExpectStatus int `json:"expectStatus,omitempty"`
}
RuleAction is one step of a campaign phase.
func (RuleAction) Status ¶
func (action RuleAction) Status() int
Status returns the expected HTTP status of a request action.
type RuleCampaign ¶
type RuleCampaign struct {
ID string `json:"id"`
Class string `json:"class"`
Description string `json:"description"`
Source string `json:"source"`
Targets []RuleTarget `json:"targets"`
Baseline []RuleAction `json:"baseline"`
Observed []RuleAction `json:"observed"`
Policies []RulePolicy `json:"policies"`
}
RuleCampaign deploys one source workload and its targets, runs baseline actions, then observed actions. A security campaign expects a rule finding in the observed window anchored to the source and its last observed target; a benign campaign expects no rule to fire. No rule may fire during setup or the baseline.
type RuleCampaignReport ¶
type RuleCampaignReport struct {
SchemaVersion string `json:"schemaVersion"`
Campaign RuleCampaign `json:"campaign"`
StartedAt time.Time `json:"startedAt"`
FinishedAt time.Time `json:"finishedAt"`
Phases []PhaseReport `json:"phases"`
Rules []RuleEvaluation `json:"rules"`
Model string `json:"model,omitempty"`
DetectorOnly bool `json:"detectorOnly,omitempty"`
Error string `json:"error,omitempty"`
}
RuleCampaignReport is the result of one rule campaign.
type RuleCatalog ¶
type RuleCatalog struct {
SchemaVersion string `json:"schemaVersion"`
Purpose string `json:"purpose"`
Campaigns []RuleCampaign `json:"campaigns"`
}
RuleCatalog is the rule-engine eval suite. Unlike the mission campaigns, each campaign is built around inputs detection rules evaluate.
func LoadRuleCatalog ¶
func LoadRuleCatalog(path string) (RuleCatalog, error)
func (RuleCatalog) Validate ¶
func (catalog RuleCatalog) Validate() error
type RuleEvaluation ¶
type RuleEvaluation struct {
Source string `json:"source"`
Rules []detector.Rule `json:"rules"`
Rationale string `json:"rationale,omitempty"`
// ObservedBehavior is the baseline profile the author was given, if any.
ObservedBehavior *state.WorkloadBehavior `json:"observedBehavior,omitempty"`
// Error records a rule that could not be produced, such as a failed authoring call.
Error string `json:"error,omitempty"`
Phases []RulePhase `json:"phases"`
// ObservedPathMatch reports a rule finding in the observed window whose signals
// anchor both observed endpoints.
ObservedPathMatch bool `json:"observedPathMatch"`
// NormalPhaseFindings counts rule findings in the setup and stabilization windows,
// which contain only expected activity.
NormalPhaseFindings int `json:"normalPhaseFindings"`
Outcome string `json:"outcome"`
MatchesExpectation bool `json:"matchesExpectation"`
}
RuleEvaluation scores one rule source for one campaign across its windows.
type RulePhase ¶
type RulePhase struct {
Phase string `json:"phase"`
Signals []detector.InvestigationSignal `json:"signals"`
Findings []state.Finding `json:"findings"`
}
RulePhase is the rule output for one window.
type RulePolicy ¶
type RulePolicy struct {
ID string `json:"id"`
Selector string `json:"selector"`
Expression string `json:"expression"`
Rationale string `json:"rationale"`
}
RulePolicy is an operator-written CEL detection rule, scoped to the campaign's source workload when the campaign runs.
type RuleSuiteSummary ¶
type RuleSuiteSummary struct {
SchemaVersion string `json:"schemaVersion"`
CompletedAt time.Time `json:"completedAt"`
Campaigns int `json:"campaigns"`
Rules map[string]*RuleSummary `json:"rules"`
Model string `json:"model,omitempty"`
DetectorOnly bool `json:"detectorOnly,omitempty"`
Variant string `json:"variant"`
// AuthorSelectors are explicit selectors offered to the author; empty uses resource-kind defaults.
AuthorSelectors []string `json:"authorSelectors,omitempty"`
}
RuleSuiteSummary aggregates the rule suite by rule source.
type RuleSummary ¶
type RuleSummary struct {
Campaigns int `json:"campaigns"`
TruePositive int `json:"truePositive"`
FalseNegative int `json:"falseNegative"`
TrueNegative int `json:"trueNegative"`
FalsePositive int `json:"falsePositive"`
SecurityRecall float64 `json:"securityRecall"`
BenignSpecificity float64 `json:"benignSpecificity"`
NormalPhaseFindings int `json:"normalPhaseFindings"`
// Abstentions counts campaigns where the source produced no rule.
Abstentions int `json:"abstentions"`
Errors int `json:"errors"`
}
RuleSummary aggregates one rule source across campaigns.
type RuleTarget ¶
type RuleTarget struct {
Name string `json:"name"`
// DenyPaths are Istio path patterns an AuthorizationPolicy denies at the waypoint with 403.
DenyPaths []string `json:"denyPaths,omitempty"`
}
RuleTarget is an HTTP service the source can call.
type RunConfig ¶
type RunConfig struct {
// Suite is SuiteMission (the default) or SuiteRules.
Suite string
CatalogPath string
DatabaseURL string
ModelEndpoint string
Model string
ReasoningEffort string
RetrievalMode string
Variant string
Kubeconfig string
OutputDir string
CampaignIDs []string
ObservationAdapter string
ValidateOnly bool
DetectorOnly bool
// AuthorSelectors, when set, restricts the selectors the rule suite's
// Resource rule author may use; empty uses resource-kind defaults.
AuthorSelectors []string
Timeout time.Duration
}
type Summary ¶
type Summary struct {
SchemaVersion string `json:"schemaVersion"`
CompletedAt time.Time `json:"completedAt"`
Campaigns int `json:"campaigns"`
DetectorOnly bool `json:"detectorOnly,omitempty"`
Detection DetectionSummary `json:"detection"`
TruePositive int `json:"truePositive"`
FalseNegative int `json:"falseNegative"`
TrueNegative int `json:"trueNegative"`
FalsePositive int `json:"falsePositive"`
ObservationFailures int `json:"observationFailures"`
SecurityRecall float64 `json:"securityRecall"`
BenignSpecificity float64 `json:"benignSpecificity"`
Usage reasoning.Usage `json:"usage"`
ModelLatencyMillis int64 `json:"modelLatencyMillis"`
Variant string `json:"variant"`
Model string `json:"model"`
RetrievalMode string `json:"retrievalMode"`
}
type WorkloadContract ¶
type WorkloadContract struct {
Namespace string
RuntimeID string
Manifest string
Source string
BaselineTarget string
ObservedTarget string
}
func RenderCampaign ¶
func RenderCampaign(campaign Campaign) WorkloadContract
func RenderRuleBackground ¶
func RenderRuleBackground() WorkloadContract
RenderRuleBackground renders the namespace of steady background traffic that runs for the whole rule suite.
func RenderRuleCampaign ¶
func RenderRuleCampaign(campaign RuleCampaign) WorkloadContract
RenderRuleCampaign renders the namespace, source client, and target services of a rule campaign. Targets with deny paths get an Istio AuthorizationPolicy that the namespace waypoint enforces with 403.