Documentation
¶
Index ¶
- Constants
- Variables
- func GetOnLoadEnv(w *AppsecRuntimeConfig) map[string]interface{}
- func GetOnMatchEnv(w *AppsecRuntimeConfig, state *AppsecRequestState, request *ParsedRequest, ...) map[string]interface{}
- func GetPostEvalEnv(w *AppsecRuntimeConfig, state *AppsecRequestState, request *ParsedRequest) map[string]interface{}
- func GetPreEvalEnv(ctx context.Context, w *AppsecRuntimeConfig, state *AppsecRequestState, ...) map[string]interface{}
- func GetRuleDebug(id int) bool
- func LoadAppsecRules(hub *cwhub.Hub) error
- func NewCrzLogger(logger *log.Entry) *crzLogger
- func SetRuleDebug(id int, debug bool)
- type AppsecCollection
- type AppsecCollectionConfig
- type AppsecConfig
- type AppsecDropInfo
- type AppsecPhaseConfig
- type AppsecRequestState
- type AppsecRuntimeConfig
- func (w *AppsecRuntimeConfig) CancelAlert(state *AppsecRequestState) error
- func (w *AppsecRuntimeConfig) CancelEvent(state *AppsecRequestState) error
- func (w *AppsecRuntimeConfig) ClearResponse(state *AppsecRequestState)
- func (w *AppsecRuntimeConfig) DisableBodyInspection(state *AppsecRequestState) error
- func (w *AppsecRuntimeConfig) DisableInBandRuleByID(id int) error
- func (w *AppsecRuntimeConfig) DisableInBandRuleByName(name string) error
- func (w *AppsecRuntimeConfig) DisableInBandRuleByTag(tag string) error
- func (w *AppsecRuntimeConfig) DisableOutBandRuleByID(id int) error
- func (w *AppsecRuntimeConfig) DisableOutBandRuleByName(name string) error
- func (w *AppsecRuntimeConfig) DisableOutBandRuleByTag(tag string) error
- func (w *AppsecRuntimeConfig) DropRequest(state *AppsecRequestState, request *ParsedRequest, reason string) error
- func (w *AppsecRuntimeConfig) GenerateResponse(response AppsecTempResponse, logger *log.Entry) (int, BodyResponse)
- func (w *AppsecRuntimeConfig) LoadAPISchemaWithName(ref string, filename string) error
- func (w *AppsecRuntimeConfig) LoadAPISchemaWithOptions(ref string, filename string, opts map[string]any) error
- func (w *AppsecRuntimeConfig) NewRequestState() AppsecRequestState
- func (w *AppsecRuntimeConfig) ProcessOnLoadRules() error
- func (w *AppsecRuntimeConfig) ProcessOnMatchRules(state *AppsecRequestState, request *ParsedRequest, evt pipeline.Event) error
- func (w *AppsecRuntimeConfig) ProcessPostEvalRules(state *AppsecRequestState, request *ParsedRequest) error
- func (w *AppsecRuntimeConfig) ProcessPreEvalRules(ctx context.Context, state *AppsecRequestState, request *ParsedRequest) error
- func (w *AppsecRuntimeConfig) RegisterAPISchemaBodyDecoder(contentType, decoderName string) error
- func (w *AppsecRuntimeConfig) RemoveInbandRuleByID(state *AppsecRequestState, id int) error
- func (w *AppsecRuntimeConfig) RemoveInbandRuleByName(state *AppsecRequestState, name string) error
- func (w *AppsecRuntimeConfig) RemoveInbandRuleByTag(state *AppsecRequestState, tag string) error
- func (w *AppsecRuntimeConfig) RemoveOutbandRuleByID(state *AppsecRequestState, id int) error
- func (w *AppsecRuntimeConfig) RemoveOutbandRuleByName(state *AppsecRequestState, name string) error
- func (w *AppsecRuntimeConfig) RemoveOutbandRuleByTag(state *AppsecRequestState, tag string) error
- func (w *AppsecRuntimeConfig) SendAlert(state *AppsecRequestState) error
- func (w *AppsecRuntimeConfig) SendEvent(state *AppsecRequestState) error
- func (w *AppsecRuntimeConfig) SetAction(state *AppsecRequestState, action string) error
- func (w *AppsecRuntimeConfig) SetActionByID(id int, action string) error
- func (w *AppsecRuntimeConfig) SetActionByName(name string, action string) error
- func (w *AppsecRuntimeConfig) SetActionByTag(tag string, action string) error
- func (w *AppsecRuntimeConfig) SetBodySizeExceededAction(action string) error
- func (w *AppsecRuntimeConfig) SetHTTPCode(state *AppsecRequestState, code int) error
- func (w *AppsecRuntimeConfig) SetMaxBodySize(size int64) error
- func (w *AppsecRuntimeConfig) ValidateRequestWithSchema(ctx context.Context, state *AppsecRequestState, request *ParsedRequest, ...) bool
- type AppsecSubEngineOpts
- type AppsecTempResponse
- type BodyResponse
- type BodySettings
- type ExtendedTransaction
- func (t *ExtendedTransaction) AddGetRequestArgument(name string, value string)
- func (t *ExtendedTransaction) AddRequestHeader(name string, value string)
- func (t *ExtendedTransaction) Close() error
- func (t *ExtendedTransaction) ID() string
- func (t *ExtendedTransaction) Interrupt(interruption *types.Interruption)
- func (t *ExtendedTransaction) Interruption() *types.Interruption
- func (t *ExtendedTransaction) IsInterrupted() bool
- func (t *ExtendedTransaction) IsRuleEngineOff() bool
- func (t *ExtendedTransaction) MatchedRules() []types.MatchedRule
- func (t *ExtendedTransaction) ProcessConnection(client string, cPort int, server string, sPort int)
- func (t *ExtendedTransaction) ProcessLogging()
- func (t *ExtendedTransaction) ProcessRequestBody() (*types.Interruption, error)
- func (t *ExtendedTransaction) ProcessRequestHeaders() *types.Interruption
- func (t *ExtendedTransaction) ProcessURI(uri string, method string, httpVersion string)
- func (t *ExtendedTransaction) RemoveRuleByIDWithError(id int) error
- func (t *ExtendedTransaction) RemoveRuleByTagWithError(tag string) error
- func (t *ExtendedTransaction) SetServerName(name string)
- func (t *ExtendedTransaction) Variables() plugintypes.TransactionVariables
- func (t *ExtendedTransaction) WriteRequestBody(body []byte) (*types.Interruption, int, error)
- type Hook
- type ParsedRequest
- type PhaseHooks
- type ReqDumpFilter
- func (r *ReqDumpFilter) FilterArgs(out *ParsedRequest) error
- func (r *ReqDumpFilter) FilterBody(out *ParsedRequest) error
- func (r *ReqDumpFilter) FilterHeaders(out *ParsedRequest) error
- func (r *ReqDumpFilter) GetFilteredRequest() *ParsedRequest
- func (r *ReqDumpFilter) NoFilters() *ReqDumpFilter
- func (r *ReqDumpFilter) ToJSON() error
- func (r *ReqDumpFilter) WithArgsContentFilter(filter string) *ReqDumpFilter
- func (r *ReqDumpFilter) WithArgsNameFilter(filter string) *ReqDumpFilter
- func (r *ReqDumpFilter) WithBody() *ReqDumpFilter
- func (r *ReqDumpFilter) WithEmptyArgsFilters() *ReqDumpFilter
- func (r *ReqDumpFilter) WithEmptyHeadersFilters() *ReqDumpFilter
- func (r *ReqDumpFilter) WithHeaders() *ReqDumpFilter
- func (r *ReqDumpFilter) WithHeadersContentFilter(filter string) *ReqDumpFilter
- func (r *ReqDumpFilter) WithHeadersNameFilter(filter string) *ReqDumpFilter
- func (r *ReqDumpFilter) WithNoBody() *ReqDumpFilter
- func (r *ReqDumpFilter) WithNoHeaders() *ReqDumpFilter
- type RulesDetails
Constants ¶
const ( BanRemediation = "ban" CaptchaRemediation = "captcha" AllowRemediation = "allow" )
const ( // BodySizeActionDrop drops the request when the body exceeds the maximum size. BodySizeActionDrop = "drop" // BodySizeActionPartial reads the body up to the maximum size and processes it. BodySizeActionPartial = "partial" // BodySizeActionAllow processes the request without inspecting the body. BodySizeActionAllow = "allow" // DefaultMaxBodySize is the default maximum body size (10MB). DefaultMaxBodySize = int64(10 * 1024 * 1024) )
const ( PhaseInBand phase = iota PhaseOutOfBand )
const ( URIHeaderName = "X-Crowdsec-Appsec-Uri" VerbHeaderName = "X-Crowdsec-Appsec-Verb" HostHeaderName = "X-Crowdsec-Appsec-Host" IPHeaderName = "X-Crowdsec-Appsec-Ip" APIKeyHeaderName = "X-Crowdsec-Appsec-Api-Key" UserAgentHeaderName = "X-Crowdsec-Appsec-User-Agent" HTTPVersionHeaderName = "X-Crowdsec-Appsec-Http-Version" TransactionIDHeaderName = "X-Crowdsec-Appsec-Transaction-Id" )
const APPSEC_RULE = "appsec-rule"
Variables ¶
var AppsecRulesDetails = make(map[int]RulesDetails)
FIXME: this shouldn't be a global Is using the id is a good idea ? might be too specific to coraza and not easily reusable
var DebugRules = map[int]bool{}
Functions ¶
func GetOnLoadEnv ¶
func GetOnLoadEnv(w *AppsecRuntimeConfig) map[string]interface{}
func GetOnMatchEnv ¶
func GetOnMatchEnv(w *AppsecRuntimeConfig, state *AppsecRequestState, request *ParsedRequest, evt pipeline.Event) map[string]interface{}
func GetPostEvalEnv ¶
func GetPostEvalEnv(w *AppsecRuntimeConfig, state *AppsecRequestState, request *ParsedRequest) map[string]interface{}
func GetPreEvalEnv ¶
func GetPreEvalEnv(ctx context.Context, w *AppsecRuntimeConfig, state *AppsecRequestState, request *ParsedRequest) map[string]interface{}
func GetRuleDebug ¶
func LoadAppsecRules ¶
func NewCrzLogger ¶
func SetRuleDebug ¶
Types ¶
type AppsecCollection ¶
func LoadCollection ¶
func (AppsecCollection) String ¶
func (w AppsecCollection) String() string
type AppsecCollectionConfig ¶
type AppsecCollectionConfig struct {
Type string `yaml:"type"`
Name string `yaml:"name"`
Debug bool `yaml:"debug"`
Description string `yaml:"description"`
SecLangFilesRules []string `yaml:"seclang_files_rules"`
SecLangRules []string `yaml:"seclang_rules"`
Rules []appsec_rule.CustomRule `yaml:"rules"`
Severity string `yaml:"severity"`
Labels map[string]any `yaml:"labels"` // Labels is K:V list aiming at providing context the overflow
Data any `yaml:"data"` // Ignore it
// contains filtered or unexported fields
}
to be filled w/ seb update
type AppsecConfig ¶
type AppsecConfig struct {
Name string `yaml:"name"`
OutOfBandRules []string `yaml:"outofband_rules"`
InBandRules []string `yaml:"inband_rules"`
DefaultRemediation string `yaml:"default_remediation"`
DefaultPassAction string `yaml:"default_pass_action"`
BouncerBlockedHTTPCode int `yaml:"blocked_http_code"` // returned to the bouncer
BouncerPassedHTTPCode int `yaml:"passed_http_code"` // returned to the bouncer
UserBlockedHTTPCode int `yaml:"user_blocked_http_code"` // returned to the user
UserPassedHTTPCode int `yaml:"user_passed_http_code"` // returned to the user
OnLoad []Hook `yaml:"on_load"`
PreEval []Hook `yaml:"pre_eval"`
PostEval []Hook `yaml:"post_eval"`
OnMatch []Hook `yaml:"on_match"`
VariablesTracking []string `yaml:"variables_tracking"`
InbandOptions AppsecSubEngineOpts `yaml:"inband_options"`
OutOfBandOptions AppsecSubEngineOpts `yaml:"outofband_options"`
InBand *AppsecPhaseConfig `yaml:"inband"`
OutOfBand *AppsecPhaseConfig `yaml:"outofband"`
LogLevel *log.Level `yaml:"log_level"`
Logger *log.Entry `yaml:"-"`
}
func (*AppsecConfig) Build ¶
func (wc *AppsecConfig) Build(ctx context.Context, hub *cwhub.Hub) (*AppsecRuntimeConfig, error)
func (*AppsecConfig) LoadByPath ¶
func (wc *AppsecConfig) LoadByPath(file string) error
func (*AppsecConfig) SetUpLogger ¶ added in v1.6.5
func (wc *AppsecConfig) SetUpLogger()
type AppsecDropInfo ¶ added in v1.7.4
type AppsecDropInfo struct {
Reason string
Interruption *corazatypes.Interruption
}
type AppsecPhaseConfig ¶ added in v1.7.8
type AppsecPhaseConfig struct {
Rules []string `yaml:"rules"`
OnMatch []Hook `yaml:"on_match"`
PreEval []Hook `yaml:"pre_eval"`
PostEval []Hook `yaml:"post_eval"`
Options AppsecSubEngineOpts `yaml:"options"`
VariablesTracking []string `yaml:"variables_tracking"`
}
AppsecPhaseConfig holds configuration scoped to a specific phase (inband or outofband). Hooks defined here are automatically dispatched only during the corresponding phase.
type AppsecRequestState ¶ added in v1.7.4
type AppsecRequestState struct {
Tx ExtendedTransaction
CurrentPhase phase
Response AppsecTempResponse
InBandDrop *AppsecDropInfo
OutOfBandDrop *AppsecDropInfo
PendingAction *string
PendingHTTPCode *int
// HookVars is a per-request scratch space exposed to expr hooks as
// `hook_vars`. Helpers (e.g. ValidateRequestWithSchema) publish string
// values here so that later hook expressions — including the `apply`
// block of the same hook — can read them. The map is allocated once in
// NewRequestState, persists across in-band/out-of-band phases, and is
// copied into pipeline.AppsecEvent.HookVars when an event is emitted.
HookVars map[string]string
DisableBodyInspection bool
}
func (*AppsecRequestState) ApplyPendingResponse ¶ added in v1.7.4
func (s *AppsecRequestState) ApplyPendingResponse()
func (*AppsecRequestState) DropInfo ¶ added in v1.7.4
func (s *AppsecRequestState) DropInfo(request *ParsedRequest) *AppsecDropInfo
func (*AppsecRequestState) ResetResponse ¶ added in v1.7.4
func (s *AppsecRequestState) ResetResponse(cfg *AppsecConfig)
type AppsecRuntimeConfig ¶
type AppsecRuntimeConfig struct {
Name string
OutOfBandRules []AppsecCollection
InBandRules []AppsecCollection
DefaultRemediation string
RemediationByTag map[string]string // Also used for ByName, as the name (for modsec rules) is a tag crowdsec-NAME
RemediationById map[int]string
CompiledOnLoad []Hook // runs once at startup, not phase-scoped
CommonHooks PhaseHooks // apply to both phases
InBandHooks PhaseHooks // only run during in-band
OutOfBandHooks PhaseHooks // only run during out-of-band
CompiledVariablesTracking []*regexp.Regexp
Config *AppsecConfig
Logger *log.Entry
// Set by on_load to ignore some rules on loading
DisabledInBandRuleIds []int
DisabledInBandRulesTags []string // Also used for ByName, as the name (for modsec rules) is a tag crowdsec-NAME
DisabledOutOfBandRuleIds []int
DisabledOutOfBandRulesTags []string // Also used for ByName, as the name (for modsec rules) is a tag crowdsec-NAME
RequestValidator *apivalidation.RequestValidator
DataDir string
// BodySettings controls how oversized request bodies are handled. Settable via on_load hooks.
BodySettings BodySettings
}
runtime version of AppsecConfig
func (*AppsecRuntimeConfig) CancelAlert ¶
func (w *AppsecRuntimeConfig) CancelAlert(state *AppsecRequestState) error
func (*AppsecRuntimeConfig) CancelEvent ¶
func (w *AppsecRuntimeConfig) CancelEvent(state *AppsecRequestState) error
func (*AppsecRuntimeConfig) ClearResponse ¶
func (w *AppsecRuntimeConfig) ClearResponse(state *AppsecRequestState)
func (*AppsecRuntimeConfig) DisableBodyInspection ¶ added in v1.7.8
func (w *AppsecRuntimeConfig) DisableBodyInspection(state *AppsecRequestState) error
DisableBodyInspection prevents Coraza from processing the request body for the current request. Intended for use in pre_eval hooks.
func (*AppsecRuntimeConfig) DisableInBandRuleByID ¶
func (w *AppsecRuntimeConfig) DisableInBandRuleByID(id int) error
Disable a rule at load time, meaning it will not run for any request
func (*AppsecRuntimeConfig) DisableInBandRuleByName ¶
func (w *AppsecRuntimeConfig) DisableInBandRuleByName(name string) error
Disable a rule at load time, meaning it will not run for any request
func (*AppsecRuntimeConfig) DisableInBandRuleByTag ¶
func (w *AppsecRuntimeConfig) DisableInBandRuleByTag(tag string) error
Disable a rule at load time, meaning it will not run for any request
func (*AppsecRuntimeConfig) DisableOutBandRuleByID ¶
func (w *AppsecRuntimeConfig) DisableOutBandRuleByID(id int) error
Disable a rule at load time, meaning it will not run for any request
func (*AppsecRuntimeConfig) DisableOutBandRuleByName ¶
func (w *AppsecRuntimeConfig) DisableOutBandRuleByName(name string) error
Disable a rule at load time, meaning it will not run for any request
func (*AppsecRuntimeConfig) DisableOutBandRuleByTag ¶
func (w *AppsecRuntimeConfig) DisableOutBandRuleByTag(tag string) error
Disable a rule at load time, meaning it will not run for any request
func (*AppsecRuntimeConfig) DropRequest ¶ added in v1.7.4
func (w *AppsecRuntimeConfig) DropRequest(state *AppsecRequestState, request *ParsedRequest, reason string) error
func (*AppsecRuntimeConfig) GenerateResponse ¶
func (w *AppsecRuntimeConfig) GenerateResponse(response AppsecTempResponse, logger *log.Entry) (int, BodyResponse)
func (*AppsecRuntimeConfig) LoadAPISchemaWithName ¶ added in v1.7.8
func (w *AppsecRuntimeConfig) LoadAPISchemaWithName(ref string, filename string) error
func (*AppsecRuntimeConfig) LoadAPISchemaWithOptions ¶ added in v1.7.8
func (w *AppsecRuntimeConfig) LoadAPISchemaWithOptions(ref string, filename string, opts map[string]any) error
LoadAPISchemaWithOptions behaves like LoadAPISchemaWithName but accepts a map of policy overrides. Supported keys:
- "on_route_not_found": "drop" | "ignore" (default: "drop")
- "on_method_not_allowed": "drop" | "ignore" (default: "drop")
- "on_unsupported_security_scheme": "drop" | "ignore" (default: "drop")
func (*AppsecRuntimeConfig) NewRequestState ¶ added in v1.7.4
func (w *AppsecRuntimeConfig) NewRequestState() AppsecRequestState
func (*AppsecRuntimeConfig) ProcessOnLoadRules ¶
func (w *AppsecRuntimeConfig) ProcessOnLoadRules() error
func (*AppsecRuntimeConfig) ProcessOnMatchRules ¶
func (w *AppsecRuntimeConfig) ProcessOnMatchRules(state *AppsecRequestState, request *ParsedRequest, evt pipeline.Event) error
func (*AppsecRuntimeConfig) ProcessPostEvalRules ¶
func (w *AppsecRuntimeConfig) ProcessPostEvalRules(state *AppsecRequestState, request *ParsedRequest) error
func (*AppsecRuntimeConfig) ProcessPreEvalRules ¶
func (w *AppsecRuntimeConfig) ProcessPreEvalRules(ctx context.Context, state *AppsecRequestState, request *ParsedRequest) error
func (*AppsecRuntimeConfig) RegisterAPISchemaBodyDecoder ¶ added in v1.7.8
func (w *AppsecRuntimeConfig) RegisterAPISchemaBodyDecoder(contentType, decoderName string) error
RegisterAPISchemaBodyDecoder allows a user's on_load hook to add a Content-Type to the set the API schema validator can decode. decoderName must be one of the stable built-in identifiers exported by the api_validation package ("json", "urlencoded", "multipart", "yaml", "csv", "plain", "file"). Note that the underlying kin-openapi decoder registry is process-global: today all appsec datasources in the same process share the same set of registered body decoders.
func (*AppsecRuntimeConfig) RemoveInbandRuleByID ¶
func (w *AppsecRuntimeConfig) RemoveInbandRuleByID(state *AppsecRequestState, id int) error
func (*AppsecRuntimeConfig) RemoveInbandRuleByName ¶
func (w *AppsecRuntimeConfig) RemoveInbandRuleByName(state *AppsecRequestState, name string) error
func (*AppsecRuntimeConfig) RemoveInbandRuleByTag ¶
func (w *AppsecRuntimeConfig) RemoveInbandRuleByTag(state *AppsecRequestState, tag string) error
func (*AppsecRuntimeConfig) RemoveOutbandRuleByID ¶
func (w *AppsecRuntimeConfig) RemoveOutbandRuleByID(state *AppsecRequestState, id int) error
func (*AppsecRuntimeConfig) RemoveOutbandRuleByName ¶
func (w *AppsecRuntimeConfig) RemoveOutbandRuleByName(state *AppsecRequestState, name string) error
func (*AppsecRuntimeConfig) RemoveOutbandRuleByTag ¶
func (w *AppsecRuntimeConfig) RemoveOutbandRuleByTag(state *AppsecRequestState, tag string) error
func (*AppsecRuntimeConfig) SendAlert ¶
func (w *AppsecRuntimeConfig) SendAlert(state *AppsecRequestState) error
func (*AppsecRuntimeConfig) SendEvent ¶
func (w *AppsecRuntimeConfig) SendEvent(state *AppsecRequestState) error
func (*AppsecRuntimeConfig) SetAction ¶
func (w *AppsecRuntimeConfig) SetAction(state *AppsecRequestState, action string) error
func (*AppsecRuntimeConfig) SetActionByID ¶
func (w *AppsecRuntimeConfig) SetActionByID(id int, action string) error
func (*AppsecRuntimeConfig) SetActionByName ¶
func (w *AppsecRuntimeConfig) SetActionByName(name string, action string) error
func (*AppsecRuntimeConfig) SetActionByTag ¶
func (w *AppsecRuntimeConfig) SetActionByTag(tag string, action string) error
func (*AppsecRuntimeConfig) SetBodySizeExceededAction ¶ added in v1.7.8
func (w *AppsecRuntimeConfig) SetBodySizeExceededAction(action string) error
SetBodySizeExceededAction sets what happens when the body exceeds the maximum size. Valid values: "drop" (block request), "partial" (inspect up to max size), "allow" (skip body inspection). Intended for use in on_load hooks.
func (*AppsecRuntimeConfig) SetHTTPCode ¶
func (w *AppsecRuntimeConfig) SetHTTPCode(state *AppsecRequestState, code int) error
func (*AppsecRuntimeConfig) SetMaxBodySize ¶ added in v1.7.8
func (w *AppsecRuntimeConfig) SetMaxBodySize(size int64) error
SetMaxBodySize sets the maximum allowed body size in bytes. Intended for use in on_load hooks.
func (*AppsecRuntimeConfig) ValidateRequestWithSchema ¶ added in v1.7.8
func (w *AppsecRuntimeConfig) ValidateRequestWithSchema(ctx context.Context, state *AppsecRequestState, request *ParsedRequest, ref string) bool
ValidateRequestWithSchema validates r against the OpenAPI schema registered under ref. It returns true when the request is valid, false when it is not (or when no schema is registered for ref). On failure, structured error details are published into state.HookVars under the "validation_error*" keys so that subsequent hook expressions (typically the `apply` block of the same hook) can build a drop reason or enrich an event. Each call also increments the AppsecValidationOKCounter / AppsecValidationFailedCounter metric.
type AppsecSubEngineOpts ¶
type AppsecTempResponse ¶
type AppsecTempResponse struct {
InBandInterrupt bool
OutOfBandInterrupt bool
Action string // allow, deny, captcha, log
UserHTTPResponseCode int // The response code to send to the user
BouncerHTTPResponseCode int // The response code to send to the remediation component
SendEvent bool // do we send an internal event on rule match
SendAlert bool // do we send an alert on rule match
}
type BodyResponse ¶
type BodySettings ¶ added in v1.7.8
type BodySettings struct {
// MaxSize is the maximum allowed body size in bytes. Defaults to DefaultMaxBodySize (10MB).
MaxSize int64 `yaml:"max_body_size"`
// Action controls what happens when a body exceeds MaxSize:
// "drop" (default) - block the request, "partial" - inspect up to MaxSize bytes, "allow" - skip body inspection.
Action string `yaml:"body_size_exceeded_action"`
}
BodySettings controls how oversized request bodies are handled.
type ExtendedTransaction ¶
type ExtendedTransaction struct {
Tx experimental.FullTransaction
}
func NewExtendedTransaction ¶
func NewExtendedTransaction(engine coraza.WAF, uuid string) ExtendedTransaction
func NewTransaction ¶
func NewTransaction(tx experimental.FullTransaction) ExtendedTransaction
func (*ExtendedTransaction) AddGetRequestArgument ¶
func (t *ExtendedTransaction) AddGetRequestArgument(name string, value string)
func (*ExtendedTransaction) AddRequestHeader ¶
func (t *ExtendedTransaction) AddRequestHeader(name string, value string)
func (*ExtendedTransaction) Close ¶ added in v1.6.6
func (t *ExtendedTransaction) Close() error
func (*ExtendedTransaction) ID ¶
func (t *ExtendedTransaction) ID() string
func (*ExtendedTransaction) Interrupt ¶ added in v1.7.4
func (t *ExtendedTransaction) Interrupt(interruption *types.Interruption)
func (*ExtendedTransaction) Interruption ¶
func (t *ExtendedTransaction) Interruption() *types.Interruption
func (*ExtendedTransaction) IsInterrupted ¶
func (t *ExtendedTransaction) IsInterrupted() bool
func (*ExtendedTransaction) IsRuleEngineOff ¶
func (t *ExtendedTransaction) IsRuleEngineOff() bool
func (*ExtendedTransaction) MatchedRules ¶
func (t *ExtendedTransaction) MatchedRules() []types.MatchedRule
func (*ExtendedTransaction) ProcessConnection ¶
func (t *ExtendedTransaction) ProcessConnection(client string, cPort int, server string, sPort int)
func (*ExtendedTransaction) ProcessLogging ¶
func (t *ExtendedTransaction) ProcessLogging()
func (*ExtendedTransaction) ProcessRequestBody ¶
func (t *ExtendedTransaction) ProcessRequestBody() (*types.Interruption, error)
func (*ExtendedTransaction) ProcessRequestHeaders ¶
func (t *ExtendedTransaction) ProcessRequestHeaders() *types.Interruption
func (*ExtendedTransaction) ProcessURI ¶
func (t *ExtendedTransaction) ProcessURI(uri string, method string, httpVersion string)
func (*ExtendedTransaction) RemoveRuleByIDWithError ¶
func (t *ExtendedTransaction) RemoveRuleByIDWithError(id int) error
func (*ExtendedTransaction) RemoveRuleByTagWithError ¶
func (t *ExtendedTransaction) RemoveRuleByTagWithError(tag string) error
func (*ExtendedTransaction) SetServerName ¶
func (t *ExtendedTransaction) SetServerName(name string)
func (*ExtendedTransaction) Variables ¶
func (t *ExtendedTransaction) Variables() plugintypes.TransactionVariables
func (*ExtendedTransaction) WriteRequestBody ¶
func (t *ExtendedTransaction) WriteRequestBody(body []byte) (*types.Interruption, int, error)
type Hook ¶
type ParsedRequest ¶
type ParsedRequest struct {
RemoteAddr string `json:"remote_addr,omitempty"`
Host string `json:"host,omitempty"`
ClientIP string `json:"client_ip,omitempty"`
URI string `json:"uri,omitempty"`
Args url.Values `json:"args,omitempty"`
ClientHost string `json:"client_host,omitempty"`
Headers http.Header `json:"headers,omitempty"`
URL *url.URL `json:"url,omitempty"`
Method string `json:"method,omitempty"`
Proto string `json:"proto,omitempty"`
Body []byte `json:"body,omitempty"`
TransferEncoding []string `json:"transfer_encoding,omitempty"`
UUID string `json:"uuid,omitempty"`
ResponseChannel chan AppsecTempResponse `json:"-"`
IsInBand bool `json:"-"`
IsOutBand bool `json:"-"`
AppsecEngine string `json:"appsec_engine,omitempty"`
RemoteAddrNormalized string `json:"normalized_remote_addr,omitempty"`
HTTPRequest *http.Request `json:"-"`
// BodyTruncated is true when the body was larger than the configured limit and was truncated (partial mode).
BodyTruncated bool `json:"body_truncated,omitempty"`
// BodySizeExceeded is true when the body exceeded the configured limit and the action is drop.
// The body is not populated in this case; a fake interruption will be triggered in the runner.
BodySizeExceeded bool `json:"body_size_exceeded,omitempty"`
}
func NewParsedRequestFromRequest ¶
func NewParsedRequestFromRequest(r *http.Request, logger *log.Entry, bodySettings BodySettings) (ParsedRequest, error)
Generate a ParsedRequest from a http.Request. ParsedRequest can be consumed by the App security Engine. bodySettings controls the maximum body size and what to do when the limit is exceeded.
func (*ParsedRequest) DumpRequest ¶
func (r *ParsedRequest) DumpRequest(params ...any) *ReqDumpFilter
type PhaseHooks ¶ added in v1.7.8
PhaseHooks bundles the three phase-scoped hook lists (pre_eval, post_eval, on_match) that run during request evaluation. OnLoad is excluded because it runs once at startup and is not phase-scoped.
type ReqDumpFilter ¶
type ReqDumpFilter struct {
HeadersContentFilters []string
HeadersNameFilters []string
HeadersDrop bool
BodyDrop bool
ArgsContentFilters []string
ArgsNameFilters []string
ArgsDrop bool
// contains filtered or unexported fields
}
func (*ReqDumpFilter) FilterArgs ¶
func (r *ReqDumpFilter) FilterArgs(out *ParsedRequest) error
func (*ReqDumpFilter) FilterBody ¶
func (r *ReqDumpFilter) FilterBody(out *ParsedRequest) error
func (*ReqDumpFilter) FilterHeaders ¶
func (r *ReqDumpFilter) FilterHeaders(out *ParsedRequest) error
func (*ReqDumpFilter) GetFilteredRequest ¶
func (r *ReqDumpFilter) GetFilteredRequest() *ParsedRequest
func (*ReqDumpFilter) ToJSON ¶
func (r *ReqDumpFilter) ToJSON() error
func (*ReqDumpFilter) WithArgsContentFilter ¶
func (r *ReqDumpFilter) WithArgsContentFilter(filter string) *ReqDumpFilter
func (*ReqDumpFilter) WithArgsNameFilter ¶
func (r *ReqDumpFilter) WithArgsNameFilter(filter string) *ReqDumpFilter
func (*ReqDumpFilter) WithBody ¶
func (r *ReqDumpFilter) WithBody() *ReqDumpFilter
func (*ReqDumpFilter) WithEmptyArgsFilters ¶
func (r *ReqDumpFilter) WithEmptyArgsFilters() *ReqDumpFilter
func (*ReqDumpFilter) WithEmptyHeadersFilters ¶
func (r *ReqDumpFilter) WithEmptyHeadersFilters() *ReqDumpFilter
func (*ReqDumpFilter) WithHeaders ¶
func (r *ReqDumpFilter) WithHeaders() *ReqDumpFilter
func (*ReqDumpFilter) WithHeadersContentFilter ¶
func (r *ReqDumpFilter) WithHeadersContentFilter(filter string) *ReqDumpFilter
func (*ReqDumpFilter) WithHeadersNameFilter ¶
func (r *ReqDumpFilter) WithHeadersNameFilter(filter string) *ReqDumpFilter
func (*ReqDumpFilter) WithNoBody ¶
func (r *ReqDumpFilter) WithNoBody() *ReqDumpFilter
func (*ReqDumpFilter) WithNoHeaders ¶
func (r *ReqDumpFilter) WithNoHeaders() *ReqDumpFilter