Documentation ¶
Index ¶
- Constants
- type WafConfig
- type WafConfigLimits
- type WafConfigObfuscator
- type WafContext
- type WafDl
- func (waf *WafDl) Close() error
- func (waf *WafDl) Handle() uintptr
- func (waf *WafDl) WafContextDestroy(context WafContext)
- func (waf *WafDl) WafContextInit(handle WafHandle) WafContext
- func (waf *WafDl) WafDestroy(handle WafHandle)
- func (waf *WafDl) WafGetVersion() string
- func (waf *WafDl) WafInit(ruleset *WafObject, config *WafConfig, info *WafObject) WafHandle
- func (waf *WafDl) WafKnownAddresses(handle WafHandle) []string
- func (waf *WafDl) WafObjectFree(obj *WafObject)
- func (waf *WafDl) WafResultFree(result *WafResult)
- func (waf *WafDl) WafRun(context WafContext, persistentData, ephemeralData *WafObject, ...) WafReturnCode
- func (waf *WafDl) WafUpdate(handle WafHandle, ruleset *WafObject, info *WafObject) WafHandle
- type WafHandle
- type WafObject
- type WafObjectType
- type WafResult
- type WafReturnCode
Constants ¶
const ( WafMaxStringLength = 4096 WafMaxContainerDepth = 20 WafMaxContainerSize = 256 WafRunTimeout = 5000 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WafConfig ¶
type WafConfig struct { Limits WafConfigLimits Obfuscator WafConfigObfuscator FreeFn uintptr }
type WafConfigLimits ¶
type WafConfigObfuscator ¶
type WafContext ¶
type WafContext uintptr
wafContext is a forward declaration in ddwaf.h header We basically don't need to modify it, only to give it to the waf
type WafDl ¶
type WafDl struct {
// contains filtered or unexported fields
}
wafDl is the type wrapper for all C calls to the waf It uses `libwaf` to make C calls All calls must go through this one-liner to be type safe since purego calls are not type safe
func NewWafDl ¶
newWafDl loads the libddwaf shared library and resolves all tge relevant symbols. The caller is responsible for calling wafDl.Close on the returned object once they are done with it so that associated resources can be released.
func (*WafDl) WafContextDestroy ¶
func (waf *WafDl) WafContextDestroy(context WafContext)
func (*WafDl) WafContextInit ¶
func (waf *WafDl) WafContextInit(handle WafHandle) WafContext
func (*WafDl) WafDestroy ¶
func (*WafDl) WafGetVersion ¶
wafGetVersion returned string is a static string so we do not need to free it
func (*WafDl) WafInit ¶
wafInit initializes a new WAF with the provided ruleset, configuration and info objects. A cgoRefPool ensures that the provided input values are not moved or garbage collected by the Go runtime during the WAF call.
func (*WafDl) WafKnownAddresses ¶
wafKnownAddresses returns static strings so we do not need to free them
func (*WafDl) WafObjectFree ¶
func (*WafDl) WafResultFree ¶
func (*WafDl) WafRun ¶
func (waf *WafDl) WafRun(context WafContext, persistentData, ephemeralData *WafObject, result *WafResult, timeout uint64) WafReturnCode
type WafHandle ¶
type WafHandle uintptr
wafHandle is a forward declaration in ddwaf.h header We basically don't need to modify it, only to give it to the waf
type WafObject ¶
type WafObject struct { ParameterName uintptr ParameterNameLength uint64 Value uintptr NbEntries uint64 Type WafObjectType // contains filtered or unexported fields }
func (*WafObject) IsInvalid ¶
isInvalid determines whether this WAF Object has the invalid type (which is the 0-value).
func (*WafObject) IsUnusable ¶
IsUnusable returns true if the wafObject has no impact on the WAF execution But we still need this kind of objects to forward map keys in case the value of the map is invalid
type WafObjectType ¶
type WafObjectType uint32
wafObjectType is an enum in C which has the size of DWORD. But DWORD is 4 bytes in amd64 and arm64 so uint32 it is.
const ( WafIntType WafObjectType = 1 << iota WafUintType WafStringType WafArrayType WafMapType WafBoolType WafFloatType WafNilType )
const WafInvalidType WafObjectType = 0
type WafReturnCode ¶
type WafReturnCode int32
const ( WafErrInternal WafReturnCode = iota - 3 WafErrInvalidObject WafErrInvalidArgument WafOK WafMatch )