Documentation
¶
Overview ¶
Package events turns the engine's security events into SecurityEvents (0002 §5.4) and holds them, bounded, until the agent sends them to the operator. Redaction happens here, before anything leaves the engine (0002 §8.3): no bodies, no query strings, no snippets from credentials, and every field the client controls truncated to its limit.
Index ¶
Constants ¶
const ( // DefaultCapacity bounds the events held while the operator is away: // about 10 MiB at the contract's field limits. DefaultCapacity = 10_000 // MaxBatch is the contract's limit on a batch. MaxBatch = 1_000 )
Defaults of the Buffer.
Variables ¶
var Redacted = []string{"Authorization", "Cookie", "Set-Cookie", "Proxy-Authorization"}
Redacted are the headers whose values never leave the engine, not even as a snippet (0002 §8.3).
Functions ¶
func New ¶
func New(src Source, req *request.Request, path string, v pipeline.Verdict, now time.Time) *eventsv1.SecurityEvent
New builds the event for a request and its verdict. path is the request's path without the query string, as the adapter logs it.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer holds events until the agent sends them, in order of time. Full, it drops the oldest and counts them: events are best effort, inspection never waits for them. Safe for concurrent use.
func (*Buffer) Add ¶
func (b *Buffer) Add(ev *eventsv1.SecurityEvent)
Add records ev, dropping the oldest event when full. It never blocks.
func (*Buffer) Collectors ¶
func (b *Buffer) Collectors() []prometheus.Collector
Collectors returns the buffer's metrics.
func (*Buffer) Next ¶
Next waits for events, then takes up to max of them (MaxBatch when 0 or more) as a batch, with the count dropped since the previous batch. It returns nil when ctx ends first.
func (*Buffer) Return ¶
func (b *Buffer) Return(batch *eventsv1.EventBatch)
Return puts back a batch that couldn't be sent, ahead of newer events, so nothing is lost while the buffer has room: the oldest are dropped first, as Add does.