corazawaf / coraza-proxy-wasm

proxy-wasm filter based on Coraza WAF
Apache License 2.0
115 stars 24 forks source link

Support APISIX to analyze response and request bodies #261

Closed meiko closed 8 months ago

meiko commented 8 months ago

The analysis of request and response bodies is not carried out because special APISIX properties are not set. The callbacks OnHttpRequestBody and OnHttpResponseBody are not called. Corresponding properties must be set in the previously called callbacks.

This is also mentioned in the APISIX documentation: "To run this callback, we need to set property wasm_process_req_body to non-empty value in" https://apisix.apache.org/docs/apisix/wasm/

I tried this in my branch of the plugin and it seems to work. proxywasm.SetProperty([]string{"wasm_process_req_body"}, []byte("true")) https://github.com/meiko/coraza-proxy-wasm/blob/2f7bcf1db525926a78a7b05b85ed6a2ddb23d238/wasmplugin/plugin.go#L285

and proxywasm.SetProperty([]string{"wasm_process_resp_body"}, []byte("true")) https://github.com/meiko/coraza-proxy-wasm/blob/2f7bcf1db525926a78a7b05b85ed6a2ddb23d238/wasmplugin/plugin.go#L526

What do you think? Can this be included in the code base of the plugin like this or something similar?

meiko commented 8 months ago

see https://github.com/corazawaf/coraza-proxy-wasm/issues/217