resolver

package
v0.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package resolver turns the cluster's WAF objects into bundle policies (0004 §4.5): each WAFPolicy's targets are expanded into concrete host / path matches, its rule sets resolved, and conflicts between policies settled. It is pure: the same objects always give the same result.

A policy that can't be resolved (a missing rule set, rules that don't compile, a conflict) keeps the version it has in the previous bundle, so a bad edit never removes or weakens protection already in force; a policy that was never resolved is left out until it is fixed. Its Accepted condition says why.

Index

Constants

View Source
const (
	ReasonAccepted          = "Accepted"
	ReasonInvalidRef        = "InvalidRef"
	ReasonConflict          = "Conflict"
	ReasonRuleCompileError  = "RuleCompileError"
	ReasonTargetUnsupported = "TargetUnsupported"
	// ReasonTargetNotAttached: an HTTPRoute target no Gateway of an
	// integration accepted; the policy doesn't apply to it.
	ReasonTargetNotAttached = "TargetNotAttached"
	// ReasonRouteOverlap: a route of the policy overlaps a route of a
	// policy in another namespace that the engine can't tell apart from it.
	ReasonRouteOverlap = "RouteOverlap"
	// ReasonRuleSetsIncompatible: the policy's rule sets compile alone but
	// not together, as the engine loads them.
	ReasonRuleSetsIncompatible = "RuleSetsIncompatible"
	// ReasonInvalidSpec: the engine can't compile the policy's spec (a
	// value admission didn't refuse); in the bundle, it would make every
	// engine refuse the bundle.
	ReasonInvalidSpec = "InvalidSpec"
	// ReasonBundleTooLarge: the bundle with the policy as it is now
	// doesn't fit its Secrets, so the policy is held back (Input.Hold).
	ReasonBundleTooLarge = "BundleTooLarge"
)

Condition reasons for Accepted.

View Source
const PolicyValid = "the policy is valid"

PolicyValid is the Accepted message of a policy that resolved with nothing to report.

View Source
const RulesLabel = "waf.inkwall.dev/rules"

RulesLabel must be set to "true" on a ConfigMap a rule set reads rules from: the operator only watches labeled ConfigMaps.

Variables

This section is empty.

Functions

func AttachedGateways added in v0.4.3

func AttachedGateways(hr *gatewayv1.HTTPRoute) []string

AttachedGateways returns the Gateways ("namespace/name") that accepted an HTTPRoute, as their status says: a parent of its parentRefs whose controller is an integration's, with Accepted True. A route no such Gateway accepted carries no traffic through a proxy the engine is in.

func CheckSpec added in v0.4.5

func CheckSpec(s wafv1alpha1.WAFPolicySpec) error

CheckSpec compiles what the engine compiles of a policy's spec besides its rules and the objects it names (rule sets, IP lists), as the bundle builder checks it: for admission, so that a spec the bundle would leave out is refused when it is saved.

func PolicyID

func PolicyID(namespace, name string) string

PolicyID is a policy's id in the bundle.

func RuleSetID

func RuleSetID(kind, namespace, name string) string

RuleSetID is a rule set's id in the bundle.

Types

type Input

type Input struct {
	Policies  []wafv1alpha1.WAFPolicy
	Ingresses []networkingv1.Ingress
	// IngressRoutes are Traefik's (traefik.io/v1alpha1); none when its
	// CRD isn't installed.
	IngressRoutes []unstructured.Unstructured
	// HTTPRoutes are Gateway API's; none when its CRDs aren't installed.
	HTTPRoutes []gatewayv1.HTTPRoute
	// VirtualServices are Istio's (networking.istio.io); none when its
	// CRD isn't installed.
	VirtualServices []unstructured.Unstructured
	RuleSets        []wafv1alpha1.WAFRuleSet
	ClusterRuleSets []wafv1alpha1.ClusterWAFRuleSet
	// IPLists are the WAFIPLists policies name in spec.ipLists.
	IPLists []wafv1alpha1.WAFIPList
	// ConfigMaps rule sets read rules from (labeled RulesLabel).
	ConfigMaps []corev1.ConfigMap
	// Previous is the bundle in force; nil when there is none.
	Previous *bundlev1.Bundle
	// CheckRules checks SecLang read from a ConfigMap
	// (coraza.CheckUserRules); inline rules were checked at admission.
	CheckRules func(string) error
	// AssumeAttached takes every HTTPRoute as accepted by its Gateways,
	// for objects read from files, which have no status.
	AssumeAttached bool
	// CheckPolicy compiles a policy with its rule sets as the engine does
	// (policy.CheckPolicy): rule sets valid alone may not be together
	// (duplicate rule IDs). Nil: not checked.
	CheckPolicy func(*bundlev1.Policy, []*bundlev1.RuleSet) error
	// Hold names the policies the bundle doesn't take as they are now,
	// with the message of their BundleTooLarge status: the bundle with
	// them doesn't fit its Secrets (the builder decides which). Each keeps
	// its previous version, as a policy that fails does, or is left out
	// if it has none.
	Hold map[types.NamespacedName]string
	// HoldRuleSets names, by id, the rule sets the bundle doesn't take as
	// they are now, with the message of their BundleTooLarge status: each
	// ships as it is in Previous, and the policies that bind it are checked
	// with that version. One Previous doesn't have isn't held.
	//
	// A held policy (Hold) whose previous version doesn't compile with the
	// rule sets of its namespace that changed holds them too: they ship as
	// they were. A ClusterWAFRuleSet is never held for a policy: when the
	// previous version doesn't compile with one that changed, the policy is
	// left out, and its status says so.
	HoldRuleSets map[string]string
}

Input is the cluster state to resolve.

type Result

type Result struct {
	// Policies sorted by id; RuleSets are the ones they use, sorted by id.
	Policies []*bundlev1.Policy
	RuleSets []*bundlev1.RuleSet
	// PolicyStatus is keyed by the WAFPolicy.
	PolicyStatus map[types.NamespacedName]Status
	// RuleSetStatus is keyed by RuleSet id (RuleSetID), for every rule set.
	RuleSetStatus map[string]Status
}

Result is what goes into the bundle, and the status of each object.

func Resolve

func Resolve(in Input) Result

Resolve resolves in.

type Status

type Status struct {
	Accepted bool
	Reason   string
	Message  string
	// Applied means the bundle enforces the policy as its spec is now:
	// not a previous version, and not left out.
	Applied bool
}

Status is a resolved Accepted condition.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL