Documentation
¶
Overview ¶
Package decide is the runtime sensor's verdict engine: given a rule match, what does the sensor do about it, right now, on this host.
Three modes:
- monitor reports every match and blocks nothing.
- guard holds a match on a rule safe to block (a request denied, an exec refused, a connection dropped) until a person confirms a block or releases it on the resolve pages, or the hold lapses to allow.
- enforce blocks matches on rules safe to block, without asking.
The rules that keep it from causing the outage it exists to prevent:
- Only a reversible action is ever held. Stopping a process cannot be undone when the hold is released, so a hold never stops one.
- A rule not from a verified feed, or one whose own start mode is log, is reported and never blocked, in any mode.
- A health check is never held: a held probe takes the workload out of its load balancer, which is the outage.
- A rule that holds too many distinct subjects in a short window trips a breaker and reverts to reporting until a person decides about it. A misfiring rule in guard mode would otherwise hold every request.
- A hold that lapses unanswered allows that subject from then on, rather than holding it again, which would turn guard into enforce by neglect.
The engine is pure: time is passed in, nothing is read from the host.
Index ¶
- func ValidMode(m string) bool
- type Action
- type Config
- type Decision
- type Engine
- func (e *Engine) Apply(d Decision)
- func (e *Engine) Decide(m Match, now time.Time) Verdict
- func (e *Engine) Mode() Mode
- func (e *Engine) Pending(now time.Time) []PendingHold
- func (e *Engine) Rule(ref RuleRef) (Rule, bool)
- func (e *Engine) SetHold(d time.Duration)
- func (e *Engine) SetMode(m Mode)
- func (e *Engine) SetRules(rules []Rule)
- func (e *Engine) Tripped() []RuleRef
- type Match
- type Mode
- type PendingHold
- type Rule
- type RuleMode
- type RuleRef
- type Verdict
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Hold is how long a guard-mode hold waits for a person.
Hold time.Duration
// BreakerSubjects distinct subjects held by one rule inside
// BreakerWindow trips that rule's breaker.
BreakerSubjects int
BreakerWindow time.Duration
}
Config tunes the engine.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig is fifteen minutes to decide, and a breaker at twenty distinct subjects in five minutes.
type Decision ¶
type Decision struct {
UUID string
Rule RuleRef
Subject string // "*" for the whole rule
Verdict string // block | allow | promote | demote | mode
Value string // the mode, for verdict "mode"
Until time.Time
Revoked bool
DecidedAt time.Time
}
Decision is a person's decision, as the platform sends it.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine holds the sensor's state. Safe for concurrent use.
func (*Engine) SetHold ¶
SetHold changes how long a new hold waits. Holds already running keep their expiry.
func (*Engine) SetMode ¶
SetMode changes the mode, as a profile change does. An invalid mode is ignored.
type Match ¶
type Match struct {
Rule RuleRef
Subject string
// Reversible is true when the response to this match can be undone: a
// denied request, a refused exec, a dropped new connection, a quarantined
// file. Stopping a running process is not.
Reversible bool
// HealthCheck marks a request on a path the operator named as a health
// check. It is never held.
HealthCheck bool
}
Match is one rule firing on one subject.
type PendingHold ¶
Pending lists live holds, soonest to lapse first.
type Rule ¶
type Rule struct {
Ref RuleRef
Mode RuleMode
// FeedMode is the start mode the feed gave the rule, which a revoked
// promote or demote returns it to.
FeedMode RuleMode
// Verified is true when the rule came from a feed whose signature and
// file hashes checked out. An unverified rule never blocks.
Verified bool
}
Rule is one loaded rule.