policy

package
v0.0.0-...-387f441 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Applications = promauto.NewCounterVec(prometheus.CounterOpts{
		Name: "anubis_policy_results",
		Help: "The results of each policy rule",
	}, []string{"rule", "action"})

	ErrChallengeRuleHasWrongAlgorithm = errors.New("config.Bot.ChallengeRules: algorithm is invalid")
)
View Source
var (
	ErrMisconfiguration = errors.New("[unexpected] policy: administrator misconfiguration")
)

Functions

func NewHeaderExistsChecker

func NewHeaderExistsChecker(key string) checker.Impl

func NewHeaderMatchesChecker

func NewHeaderMatchesChecker(header, rexStr string) (checker.Impl, error)

func NewHeadersChecker

func NewHeadersChecker(headermap map[string]string) (checker.Impl, error)

func NewPathChecker

func NewPathChecker(rexStr string) (checker.Impl, error)

func NewRemoteAddrChecker

func NewRemoteAddrChecker(cidrs []string) (checker.Impl, error)

func NewUserAgentChecker

func NewUserAgentChecker(rexStr string) (checker.Impl, error)

Types

type Bot

type Bot struct {
	Rules     checker.Impl
	Challenge *config.ChallengeRules
	Weight    *config.Weight
	Name      string
	Action    config.Rule
}

func (Bot) Hash

func (b Bot) Hash() string

type CELChecker

type CELChecker struct {
	// contains filtered or unexported fields
}

func NewCELChecker

func NewCELChecker(cfg *config.ExpressionOrList) (*CELChecker, error)

func (*CELChecker) Check

func (cc *CELChecker) Check(r *http.Request) (bool, error)

func (*CELChecker) Hash

func (cc *CELChecker) Hash() string

type CELRequest

type CELRequest struct {
	*http.Request
}

func (*CELRequest) Parent

func (cr *CELRequest) Parent() cel.Activation

func (*CELRequest) ResolveName

func (cr *CELRequest) ResolveName(name string) (any, bool)

type CheckResult

type CheckResult struct {
	Name   string
	Rule   config.Rule
	Weight int
}

func (CheckResult) LogValue

func (cr CheckResult) LogValue() slog.Value

type HeaderMatchesChecker

type HeaderMatchesChecker struct {
	// contains filtered or unexported fields
}

func (*HeaderMatchesChecker) Check

func (hmc *HeaderMatchesChecker) Check(r *http.Request) (bool, error)

func (*HeaderMatchesChecker) Hash

func (hmc *HeaderMatchesChecker) Hash() string

type ParsedConfig

type ParsedConfig struct {
	Bots              []Bot
	Thresholds        []*Threshold
	DNSBL             bool
	Impressum         *config.Impressum
	OpenGraph         config.OpenGraph
	DefaultDifficulty int
	StatusCodes       config.StatusCodes
	Store             store.Interface
	// contains filtered or unexported fields
}

func ParseConfig

func ParseConfig(ctx context.Context, fin io.Reader, fname string, defaultDifficulty int) (*ParsedConfig, error)

type PathChecker

type PathChecker struct {
	// contains filtered or unexported fields
}

func (*PathChecker) Check

func (pc *PathChecker) Check(r *http.Request) (bool, error)

func (*PathChecker) Hash

func (pc *PathChecker) Hash() string

type RemoteAddrChecker

type RemoteAddrChecker struct {
	// contains filtered or unexported fields
}

func (*RemoteAddrChecker) Check

func (rac *RemoteAddrChecker) Check(r *http.Request) (bool, error)

func (*RemoteAddrChecker) Hash

func (rac *RemoteAddrChecker) Hash() string

type Threshold

type Threshold struct {
	config.Threshold
	Program cel.Program
}

func ParsedThresholdFromConfig

func ParsedThresholdFromConfig(t config.Threshold) (*Threshold, error)

type ThresholdRequest

type ThresholdRequest struct {
	Weight int
}

func (*ThresholdRequest) Parent

func (tr *ThresholdRequest) Parent() cel.Activation

func (*ThresholdRequest) ResolveName

func (tr *ThresholdRequest) ResolveName(name string) (any, bool)

Directories

Path Synopsis
Package checker defines the Checker interface and a helper utility to avoid import cycles.
Package checker defines the Checker interface and a helper utility to avoid import cycles.

Jump to

Keyboard shortcuts

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