resolver

package
v0.4.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 16 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"
)

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 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
	// 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
}

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