Documentation
¶
Index ¶
- Constants
- type WAFBuilder
- type WAFConfig
- type WAFConfigLimits
- type WAFConfigObfuscator
- type WAFContext
- type WAFHandle
- type WAFLib
- func (waf *WAFLib) BuilderAddOrUpdateConfig(builder WAFBuilder, path string, config *WAFObject, diags *WAFObject) bool
- func (waf *WAFLib) BuilderBuildInstance(builder WAFBuilder) WAFHandle
- func (waf *WAFLib) BuilderDestroy(builder WAFBuilder)
- func (waf *WAFLib) BuilderGetConfigPaths(builder WAFBuilder, filter string) []string
- func (waf *WAFLib) BuilderInit(cfg *WAFConfig) WAFBuilder
- func (waf *WAFLib) BuilderRemoveConfig(builder WAFBuilder, path string) bool
- func (waf *WAFLib) Close() error
- func (waf *WAFLib) ContextDestroy(context WAFContext)
- func (waf *WAFLib) ContextInit(handle WAFHandle) WAFContext
- func (waf *WAFLib) Destroy(handle WAFHandle)
- func (waf *WAFLib) GetVersion() string
- func (waf *WAFLib) Handle() uintptr
- func (waf *WAFLib) KnownActions(handle WAFHandle) []string
- func (waf *WAFLib) KnownAddresses(handle WAFHandle) []string
- func (waf *WAFLib) ObjectFree(obj *WAFObject)
- func (waf *WAFLib) ResultFree(result *WAFResult)
- func (waf *WAFLib) Run(context WAFContext, persistentData, ephemeralData *WAFObject, ...) WAFReturnCode
- func (waf *WAFLib) SetLogCb(cb uintptr, level log.Level)
- type WAFObject
- func (w *WAFObject) IsArray() bool
- func (w *WAFObject) IsBool() bool
- func (w *WAFObject) IsFloat() bool
- func (w *WAFObject) IsInt() bool
- func (w *WAFObject) IsInvalid() bool
- func (w *WAFObject) IsMap() bool
- func (w *WAFObject) IsNil() bool
- func (w *WAFObject) IsUint() bool
- func (w *WAFObject) IsUnusable() bool
- func (w *WAFObject) SetArray(pinner pin.Pinner, capacity uint64) []WAFObject
- func (w *WAFObject) SetBool(b bool)
- func (w *WAFObject) SetFloat(f float64)
- func (w *WAFObject) SetInt(i int64)
- func (w *WAFObject) SetInvalid()
- func (w *WAFObject) SetMap(pinner pin.Pinner, capacity uint64) []WAFObject
- func (w *WAFObject) SetMapKey(pinner pin.Pinner, key string)
- func (w *WAFObject) SetNil()
- func (w *WAFObject) SetString(pinner pin.Pinner, str string)
- func (w *WAFObject) SetUint(i uint64)
- type WAFObjectType
- type WAFResult
- type WAFReturnCode
Constants ¶
const ( MaxStringLength = 4096 MaxContainerDepth = 20 MaxContainerSize = 256 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type WAFBuilder ¶
type WAFBuilder uintptr
WAFBuilder is a forward declaration in ddwaf.h header We basically don't need to modify it, only to give it to the waf
type WAFConfig ¶
type WAFConfig struct {
Limits WAFConfigLimits
Obfuscator WAFConfigObfuscator
FreeFn uintptr
// contains filtered or unexported fields
}
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 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 WAFLib ¶
type WAFLib struct {
// contains filtered or unexported fields
}
WAFLib 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 NewWAFLib ¶
NewWAFLib 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 (*WAFLib) BuilderAddOrUpdateConfig ¶
func (waf *WAFLib) BuilderAddOrUpdateConfig(builder WAFBuilder, path string, config *WAFObject, diags *WAFObject) bool
BuilderAddOrUpdateConfig adds or updates a configuration based on the given path, which must be a unique identifier for the provided configuration. Returns false in case of an error.
func (*WAFLib) BuilderBuildInstance ¶
func (waf *WAFLib) BuilderBuildInstance(builder WAFBuilder) WAFHandle
BuilderBuildInstance builds a WAF instance based on the current set of configurations. Returns nil in case of an error.
func (*WAFLib) BuilderDestroy ¶
func (waf *WAFLib) BuilderDestroy(builder WAFBuilder)
BuilderDestroy destroys a WAF builder instance.
func (*WAFLib) BuilderGetConfigPaths ¶
func (waf *WAFLib) BuilderGetConfigPaths(builder WAFBuilder, filter string) []string
BuilderGetConfigPaths returns the list of currently loaded paths. Returns nil in case of an error.
func (*WAFLib) BuilderInit ¶
func (waf *WAFLib) BuilderInit(cfg *WAFConfig) WAFBuilder
BuilderInit initializes a new WAF builder with the provided configuration, which may be nil. Returns nil in case of an error.
func (*WAFLib) BuilderRemoveConfig ¶
func (waf *WAFLib) BuilderRemoveConfig(builder WAFBuilder, path string) bool
BuilderRemoveConfig removes a configuration based on the provided path. Returns false in case of an error.
func (*WAFLib) ContextDestroy ¶
func (waf *WAFLib) ContextDestroy(context WAFContext)
func (*WAFLib) ContextInit ¶
func (waf *WAFLib) ContextInit(handle WAFHandle) WAFContext
func (*WAFLib) GetVersion ¶
GetVersion returned string is a static string so we do not need to free it
func (*WAFLib) KnownActions ¶
func (*WAFLib) KnownAddresses ¶
func (*WAFLib) ObjectFree ¶
func (*WAFLib) ResultFree ¶
func (*WAFLib) Run ¶
func (waf *WAFLib) Run(context WAFContext, persistentData, ephemeralData *WAFObject, result *WAFResult, timeout uint64) WAFReturnCode
type WAFObject ¶
type WAFObject struct {
ParameterName uintptr
ParameterNameLength uint64
Value uintptr
NbEntries uint64
Type WAFObjectType
// contains filtered or unexported fields
}
func (*WAFObject) IsBool ¶ added in v4.1.0
IsBool determines whether this WAF Object is a bool or not.
func (*WAFObject) IsFloat ¶ added in v4.1.0
IsFloat determines whether this WAF Object is a float or not.
func (*WAFObject) IsInvalid ¶
IsInvalid determines whether this WAF Object has the invalid type (which is the 0-value).
func (*WAFObject) IsUint ¶ added in v4.1.0
IsUint determines whether this WAF Object is a uint or not.
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
func (*WAFObject) SetArray ¶
SetArray sets the receiving WAFObject to a new array with the given capacity.
func (*WAFObject) SetBool ¶ added in v4.1.0
SetBool sets the receiving WAFObject value to the given bool.
func (*WAFObject) SetFloat ¶ added in v4.1.0
SetFloat sets the receiving WAFObject value to the given float.
func (*WAFObject) SetInt ¶ added in v4.1.0
SetInt sets the receiving WAFObject value to the given int.
func (*WAFObject) SetInvalid ¶ added in v4.1.0
func (w *WAFObject) SetInvalid()
SetInvalid sets the receiving WAFObject to invalid.
func (*WAFObject) SetMap ¶
SetMap sets the receiving WAFObject to a new map with the given capacity.
func (*WAFObject) SetMapKey ¶
SetMapKey sets the receiving WAFObject to a new map key with the given string.
func (*WAFObject) SetNil ¶ added in v4.1.0
func (w *WAFObject) SetNil()
SetNil sets the receiving WAFObject to nil.
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
func (WAFObjectType) String ¶
func (w WAFObjectType) String() string
type WAFReturnCode ¶
type WAFReturnCode int32
const ( WAFErrInternal WAFReturnCode = iota - 3 WAFErrInvalidObject WAFErrInvalidArgument WAFOK WAFMatch )