waf

package
v1.48.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Health

func Health() error

Health allows knowing if the WAF can be used. It returns a nil error when the WAF library is healthy. Otherwise, it returns an error describing the issue.

func Version

func Version() string

Version returns the current version of the WAF

Types

type AtomicU64 added in v1.38.0

type AtomicU64 uint64

AtomicU64 can be used to perform atomic operations on an uint64 type

func (*AtomicU64) Add added in v1.38.0

func (a *AtomicU64) Add(v uint64)

Add atomically sums the current atomic value with the provided value `v`.

func (*AtomicU64) Inc added in v1.38.0

func (a *AtomicU64) Inc()

Inc atomically increments the atomic value by 1

func (*AtomicU64) Load added in v1.38.0

func (a *AtomicU64) Load() uint64

Load atomically loads the value.

type Context

type Context struct{}

Context is a WAF execution context.

func NewContext

func NewContext(*Handle) *Context

NewContext a new WAF context and increase the number of references to the WAF handle. A nil value is returned when the WAF handle can no longer be used or the WAF context couldn't be created.

func (*Context) Close

func (*Context) Close()

Close the WAF context by releasing its C memory and decreasing the number of references to the WAF handle.

func (*Context) Run

func (*Context) Run(map[string]interface{}, time.Duration) ([]byte, []string, error)

Run the WAF with the given Go values and timeout.

func (*Context) TotalRuntime added in v1.38.0

func (*Context) TotalRuntime() (uint64, uint64)

TotalRuntime returns the cumulated WAF runtime across various run calls within the same WAF context. Returned time is in nanoseconds.

func (*Context) TotalTimeouts added in v1.38.0

func (*Context) TotalTimeouts() uint64

TotalTimeouts returns the cumulated amount of WAF timeouts across various run calls within the same WAF context.

type Handle

type Handle struct{}

Handle represents an instance of the WAF for a given ruleset.

func NewHandle

func NewHandle([]byte, string, string) (*Handle, error)

NewHandle creates a new instance of the WAF with the given JSON rule.

func (*Handle) Addresses

func (*Handle) Addresses() []string

Addresses returns the list of addresses the WAF rule is expecting.

func (*Handle) Close

func (*Handle) Close()

Close the WAF and release the underlying C memory as soon as there are no more WAF contexts using the rule.

func (*Handle) RulesetInfo added in v1.38.0

func (*Handle) RulesetInfo() RulesetInfo

RulesetInfo returns the rules initialization metrics for the current WAF handle

func (*Handle) UpdateRulesData added in v1.45.0

func (*Handle) UpdateRulesData([]rc.ASMDataRuleData) error

UpdateRulesData updates the data that some rules reference to. The given rule data must be a raw JSON string of the form [ {rule data #1}, ... {rule data #2} ]

type RulesetInfo added in v1.38.0

type RulesetInfo struct {
	// Number of rules successfully loaded
	Loaded uint16
	// Number of rules which failed to parse
	Failed uint16
	// Map from an error string to an array of all the rule ids for which
	// that error was raised. {error: [rule_ids]}
	Errors map[string]interface{}
	// Ruleset version
	Version string
}

RulesetInfo stores the information - provided by the WAF - about WAF rules initialization.

type RunError

type RunError int

RunError the WAF can return when running it.

const (
	ErrInternal RunError = iota + 1
	ErrInvalidObject
	ErrInvalidArgument
	ErrTimeout
	ErrOutOfMemory
	ErrEmptyRuleAddresses
)

Errors the WAF can return when running it.

func (RunError) Error

func (e RunError) Error() string

Error returns the string representation of the RunError.

Directories

Path Synopsis
Package include is required to help go tools support vendoring.
Package include is required to help go tools support vendoring.
lib
darwin-amd64
Package vendor is required to help go tools support vendoring.
Package vendor is required to help go tools support vendoring.
darwin-arm64
Package vendor is required to help go tools support vendoring.
Package vendor is required to help go tools support vendoring.
linux-amd64
Package vendor is required to help go tools support vendoring.
Package vendor is required to help go tools support vendoring.
linux-arm64
Package vendor is required to help go tools support vendoring.
Package vendor is required to help go tools support vendoring.

Jump to

Keyboard shortcuts

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