Documentation
¶
Overview ¶
Package behavior maintains scoped, passive observations and approved baselines.
Index ¶
- Constants
- func SeedTemplate(source, target string) error
- func WriteHealth(output string, health Health) error
- type Activity
- type AlertSink
- type AssetContext
- type AssetLabel
- type AssetRecord
- type CaptureHealth
- type Config
- type Decision
- type DeliveryHealth
- type Engine
- func (e *Engine) AddPrefix(scope Scope, prefix, provenance string) error
- func (e *Engine) Change(action string, ids []string, reason string) error
- func (e *Engine) ChangeAtVersion(action string, ids []string, reason string, version uint64) error
- func (e *Engine) Checkpoint() error
- func (e *Engine) Close() error
- func (e *Engine) EditInventory(edit InventoryEdit) error
- func (e *Engine) Fail(err error)
- func (e *Engine) Health(output string, capture *CaptureHealth, delivery *DeliveryHealth) Health
- func (e *Engine) Observe(at time.Time, facts ...Fact) error
- func (e *Engine) Snapshot() Snapshot
- type Evidence
- type Fact
- type Health
- type InventoryEdit
- type Lease
- type Maintenance
- type Mode
- type Observation
- type Policy
- type RateModel
- type RateStats
- type RecordContext
- type Scope
- type Snapshot
- type Topology
- type TopologyLink
- type TopologyNode
Constants ¶
const HealthFilename = "BehaviorHealth.json"
const SchemaVersion = 3
Variables ¶
This section is empty.
Functions ¶
func SeedTemplate ¶
SeedTemplate copies a validated snapshot into a new session, never overwriting an existing session baseline or allowing that session to mutate the source.
func WriteHealth ¶
Types ¶
type AssetContext ¶
type AssetContext struct {
Asset string `json:"asset"`
Records []AssetRecord `json:"records"`
TotalRecords int `json:"totalRecords"`
Truncated bool `json:"truncated"`
}
func BuildAssetContext ¶
func BuildAssetContext(state Snapshot, asset string) (AssetContext, error)
BuildAssetContext joins bindings only within their original network scope.
type AssetLabel ¶
type AssetRecord ¶
type AssetRecord struct {
ID string `json:"id"`
Observation Observation `json:"observation"`
Label *AssetLabel `json:"label,omitempty"`
Direction string `json:"direction"`
Prefixes []string `json:"prefixes,omitempty"`
PrefixesTruncated bool `json:"prefixesTruncated,omitempty"`
}
type CaptureHealth ¶
type CaptureHealth struct {
Scope Scope `json:"scope"`
Packets uint64 `json:"packets"`
QueueDrops *uint64 `json:"queueDrops"`
KernelDrops *uint64 `json:"kernelDrops"`
KernelReceived *uint64 `json:"kernelReceived"`
StatsAt int64 `json:"statsAt"`
StatsError string `json:"statsError,omitempty"`
Workers int `json:"workers"`
Queued int `json:"queued"`
QueueCapacity int `json:"queueCapacity"`
}
type DeliveryHealth ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) AddPrefix ¶
AddPrefix seeds authoritative prefix metadata at the next capture timestamp.
func (*Engine) Change ¶
Change records an explicit analyst action and commits it atomically. ids are required for acknowledge, approve-changes, suppress and unsuppress.
func (*Engine) ChangeAtVersion ¶
func (*Engine) Checkpoint ¶
func (*Engine) EditInventory ¶
func (e *Engine) EditInventory(edit InventoryEdit) error
func (*Engine) Health ¶
func (e *Engine) Health(output string, capture *CaptureHealth, delivery *DeliveryHealth) Health
type Evidence ¶
type Evidence struct {
Related []Fact `json:"related,omitempty"`
Count int `json:"count,omitempty"`
WindowNS int64 `json:"windowNS,omitempty"`
Schema int `json:"schema"`
Detector string `json:"detector"`
FactID string `json:"factId"`
Observed Fact `json:"observed"`
Expected string `json:"expected"`
Version uint64 `json:"baselineVersion"`
BaselineID string `json:"baselineId"`
}
type Fact ¶
type Fact struct {
LeaseSeconds uint32 `json:"leaseSeconds,omitempty"`
Bytes uint64 `json:"bytes,omitempty"`
Token string `json:"token,omitempty"`
Scope Scope `json:"scope"`
Kind string `json:"kind"`
SrcIP string `json:"srcIP,omitempty"`
DstIP string `json:"dstIP,omitempty"`
MAC string `json:"mac,omitempty"`
Protocol string `json:"protocol,omitempty"`
Port uint16 `json:"port,omitempty"`
Value string `json:"value,omitempty"`
Provenance string `json:"provenance,omitempty"`
}
Fact is a reproducible observation identity. Port is a destination service port.
type Health ¶
type Health struct {
Schema int `json:"schema"`
SampledAt int64 `json:"sampledAt"`
Active bool `json:"active"`
Scopes []Scope `json:"scopes"`
ScopesTruncated bool `json:"scopesTruncated"`
Capture *CaptureHealth `json:"capture"`
Delivery *DeliveryHealth `json:"delivery"`
DetectorError string `json:"detectorError,omitempty"`
Observations uint64 `json:"observations"`
FactOverflow uint64 `json:"factOverflow"`
WindowOverflow uint64 `json:"windowOverflow"`
BaselineBytes *int64 `json:"baselineBytes"`
BaselineWrittenAt int64 `json:"baselineWrittenAt"`
AlertBytes *int64 `json:"alertBytes"`
StorageError string `json:"storageError,omitempty"`
}
func BuildHealth ¶
func BuildHealth(state Snapshot, baseline, output string, active bool, capture *CaptureHealth, delivery *DeliveryHealth) Health
func ReadHealth ¶
type InventoryEdit ¶
type Maintenance ¶
type Observation ¶
type Policy ¶
type Policy struct {
Maintenance []Maintenance `json:"maintenance,omitempty"`
DeniedCountries []string `json:"deniedCountries,omitempty"`
DeniedASNs []string `json:"deniedASNs,omitempty"`
RateWindows uint64 `json:"rateWindows"`
RateMultiplier float64 `json:"rateMultiplier"`
WindowNS int64 `json:"windowNS"`
Fanout int `json:"fanout"`
RDPAttempts int `json:"rdpAttempts"`
ApprovedSources []string `json:"approvedSources,omitempty"`
}
func DefaultPolicy ¶
func DefaultPolicy() Policy
func LoadPolicy ¶
type RecordContext ¶
type RecordContext struct {
Type string `json:"type"`
Index int `json:"index"`
SHA256 string `json:"sha256"`
FirstSeen int64 `json:"firstSeen"`
LastSeen int64 `json:"lastSeen"`
CaptureLagNS int64 `json:"captureLagNS"`
ScopeAvailable bool `json:"scopeAvailable"`
Outcome string `json:"outcome"`
Authentication string `json:"authentication"`
Command int32 `json:"command,omitempty"`
Status uint32 `json:"status,omitempty"`
Response bool `json:"response,omitempty"`
Encrypted bool `json:"encrypted,omitempty"`
}
RecordContext supplements immutable early evidence; legacy audit records lack network scope.
func MatchLateralRecord ¶
MatchLateralRecord returns a tuple/time candidate, never a scope-qualified attribution.
type Snapshot ¶
type Snapshot struct {
Labels map[string]AssetLabel `json:"labels"`
Corrections map[string]Fact `json:"corrections"`
Leases map[string]Lease `json:"leases"`
Rates map[string]RateStats `json:"rates"`
ApprovedRates map[string]RateModel `json:"approvedRates"`
Policy Policy `json:"policy"`
Activity map[string]Activity `json:"activity"`
WindowOverflow uint64 `json:"windowOverflow"`
Error string `json:"error,omitempty"`
Schema int `json:"schema"`
Mode Mode `json:"mode"`
ResumeMode Mode `json:"resumeMode,omitempty"`
Version uint64 `json:"version"`
BaselineID string `json:"baselineId"`
LearningStarted int64 `json:"learningStarted"`
Watermark int64 `json:"watermark"`
Samples uint64 `json:"samples"`
Overflow uint64 `json:"overflow"`
OutOfOrder uint64 `json:"outOfOrder"`
MinLearningNS int64 `json:"minLearningNS"`
MinSamples uint64 `json:"minSamples"`
MaxFacts int `json:"maxFacts"`
Observed map[string]Observation `json:"observed"`
Approved map[string]Fact `json:"approved"`
Suppressed map[string]string `json:"suppressed"`
Decisions []Decision `json:"decisions"`
}
func ReadSnapshot ¶
type Topology ¶
type Topology struct {
Nodes []TopologyNode `json:"nodes"`
Links []TopologyLink `json:"links"`
TotalNodes int `json:"totalNodes"`
TotalLinks int `json:"totalLinks"`
Truncated bool `json:"truncated"`
}