go-agent: github.com/sqreen/go-agent/agent/internal/rule/callback Index | Files

package callback

import "github.com/sqreen/go-agent/agent/internal/rule/callback"

Index

Package Files

add-security-headers.go monitor-http-status-code.go types.go waf.go write-custom-error-page.go write-http-redirection.go

Variables

var WAFProtectionError = errors.New("waf protection triggered")

func NewAddSecurityHeadersCallbacks Uses

func NewAddSecurityHeadersCallbacks(rule Context, nextProlog sqhook.PrologCallback) (prolog interface{}, err error)

NewAddSecurityHeadersCallbacks returns the native prolog and epilog callbacks to be hooked to `sqhttp.MiddlewareWithError` in order to add HTTP headers provided by the rule's data.

func NewMonitorHTTPStatusCodeCallbacks Uses

func NewMonitorHTTPStatusCodeCallbacks(rule Context, nextProlog sqhook.PrologCallback) (prolog interface{}, err error)

func NewWAFCallback Uses

func NewWAFCallback(rule Context, nextProlog sqhook.PrologCallback) (callback interface{}, err error)

func NewWriteCustomErrorPageCallbacks Uses

func NewWriteCustomErrorPageCallbacks(rule Context, nextProlog sqhook.PrologCallback) (prolog interface{}, err error)

NewWriteCustomErrorPageCallbacks returns the native prolog and epilog callbacks modifying the arguments of `httphandler.WriteResponse` in order to modify the http status code and error page that are provided by the rule's data.

func NewWriteHTTPRedirectionCallbacks Uses

func NewWriteHTTPRedirectionCallbacks(rule Context, nextProlog sqhook.PrologCallback) (prolog interface{}, err error)

NewWriteHTTPRedirectionCallbacks returns the native prolog and epilog callbacks modifying the arguments of `httphandler.WriteResponse` in order to modify the http status code and headers in order to perform an HTTP redirection to the URL provided by the rule's data.

type AddSecurityHeadersEpilogCallbackType Uses

type AddSecurityHeadersEpilogCallbackType = func(*error)

type AddSecurityHeadersPrologCallbackType Uses

type AddSecurityHeadersPrologCallbackType = func(*http.ResponseWriter) (AddSecurityHeadersEpilogCallbackType, error)

type Context Uses

type Context interface {
    // Get the rule configuration.
    Config() interface{}
    // Push a new metrics value for the given key into the default metrics store
    // given by the rule.
    PushMetricsValue(key interface{}, value uint64)
    // NewAttack creates and returns a new attack event linked to the rule.
    NewAttack(blocked bool, infos interface{}) *record.AttackEvent
    // BlockingMode returns true when a callback should block when an attack is
    // detected. It should monitor otherwise.
    // FIXME: rather implement a method allowing to report or block a request
    BlockingMode() bool
    // ErrorLogger allows to log errors from callbacks. It is restricted to
    // errors only as logs are expensive and should not be used for debugging
    // logs.
    plog.ErrorLogger
}

type MonitorHTTPStatusCodeEpilogCallbackType Uses

type MonitorHTTPStatusCodeEpilogCallbackType = func()

type MonitorHTTPStatusCodePrologCallbackType Uses

type MonitorHTTPStatusCodePrologCallbackType = func(sqhook.MethodReceiver, *int) (MonitorHTTPStatusCodeEpilogCallbackType, error)

type WAFEpilogCallbackType Uses

type WAFEpilogCallbackType = func(*error)

type WAFPrologCallbackType Uses

type WAFPrologCallbackType = func(*http.ResponseWriter, **http.Request) (WAFEpilogCallbackType, error)

type WriteCustomErrorPageEpilogCallbackType Uses

type WriteCustomErrorPageEpilogCallbackType = func()

type WriteCustomErrorPagePrologCallbackType Uses

type WriteCustomErrorPagePrologCallbackType = func(*http.ResponseWriter, **http.Request, *http.Header, *int, *[]byte) (WriteCustomErrorPageEpilogCallbackType, error)

type WriteHTTPRedirectionEpilogCallbackType Uses

type WriteHTTPRedirectionEpilogCallbackType = func()

type WriteHTTPRedirectionPrologCallbackType Uses

type WriteHTTPRedirectionPrologCallbackType = func(*http.ResponseWriter, **http.Request, *http.Header, *int, *[]byte) (WriteHTTPRedirectionEpilogCallbackType, error)

Package callback imports 15 packages (graph) and is imported by 1 packages. Updated 2020-02-17. Refresh now. Tools for package owners.