Open matheustmattioli opened 2 weeks ago
Hello: I ran into this same issue and was not able to get it to work. I ended up leveraging the audit log for this purpose. If add mode "K" to SecAuditLogParts it will include all of the rules that matched. This is very verbose because it also shows the full definition of each rule, but it does include all of the needed info. You can also include headers in the audit log message, so that should show the x-request-id.
I didn't like this last part because I cannot risk accidentally showing sensitive headers in the logs so I added a custom rule to specifically show the x-request-id header. The audit log message will include this along with the other matches.
Hello, I'm currently having the same issue as coraza #1119. I posted the text below in the linked issue. But I'm posting it again in a new issue because I thought maybe this repository is a better place.
Is there a way to include the x-request-id header in coraza logs as an additional tag or field like "unique_id" in each rule? I tried to implement it locally but I couldn't modify the rules metadata with actions in .conf files. Or even through the "Matched Rules" transaction variable in plugin.go file. For example at the function "OnHttpRequestHeaders" I got the header with
ctx.requestID, err = proxywasm.GetHttpRequestHeader("x-request-id")
and appended it to logFields:logFields = append(logFields, debuglog.Str("x-request-id", ctx.requestID))
.But it only logged this information in non-rule messages, like:
And nothing happened in rule messages, like:
In the same function, I tried to access the rules captured by the transaction (as in the snippet below), but it did not work because I could only get the values, and not set new values (I noticed there are no "set" methods).
Is there another way to implement this idea in the coraza-proxy-wasm version?