Documentation
¶
Overview ¶
Package policy enforces a bundle: each policy of the bundle gets its own pipeline (mode, failure mode, timeout, skip paths, rules, body settings), and each request is inspected by the policy of its route. A Holder swaps the active set atomically when a new bundle arrives.
Index ¶
Constants ¶
const MaxBodyBytes = 10 << 20
MaxBodyBytes is the largest body a policy may inspect, as WAFPolicy's body.maxBytes allows; adapters in bundle mode accept bodies up to it.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Evaluators ¶
type Evaluators struct {
// contains filtered or unexported fields
}
Evaluators caches compiled rule sets by configuration (coraza.Config.Key, without exclusions): policies with the same rules share one (a Coraza WAF with the CRS holds megabytes) whatever their exclusions, and an unchanged policy isn't recompiled when a new bundle arrives. Cached evaluators have no exclusions.
type Holder ¶
type Holder struct {
// DenyBeforeFirst rejects requests with 503 until the first set is
// stored, instead of letting them through uninspected.
DenyBeforeFirst bool
// contains filtered or unexported fields
}
Holder holds the active Set, swapped atomically: Check runs entirely on the set it loaded. (An adapter's BodyLimit and Check calls may straddle a swap; the request is then inspected by the new set, with the body read to the old set's limit.) Before the first set it allows every request, with ReasonNoPolicy, or denies it with DenyBeforeFirst.
type Options ¶
type Options struct {
// Admission bounds concurrent evaluations across all policies.
Admission *pipeline.Admission
// Observer is told about every verdict (metrics).
Observer pipeline.Observer
// MaxArgs is the argument limit (coraza.Config.MaxArgs).
MaxArgs int
// BodyLimit is the body inspected for a policy that doesn't set one.
BodyLimit int64
// OnMatch is called for every matching rule (coraza.Config.OnMatch).
OnMatch func(types.MatchedRule)
// Evaluators reuses compiled rule sets across bundles; nil compiles
// every bundle from scratch.
Evaluators *Evaluators
// Stats counts each policy's requests, for the operator (nil: not
// counted).
Stats *events.Stats
}
Options are the engine-wide settings every policy shares.
type Policy ¶
type Policy struct {
ID string
// contains filtered or unexported fields
}
Policy is one compiled policy.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a compiled bundle. It is immutable and safe for concurrent use.
func Compile ¶
Compile compiles a bundle. An error names the policy that failed: the engine then keeps the set it has (and reports the error to the operator).
func (*Set) BodyLimit ¶
BodyLimit implements pipeline.Inspector: the policy's body limit, or 0 when its bodies, or the route's, are not inspected.