-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Error message templating #186
Comments
Hmmm... what about sending the audit log instead to elastic? |
I thought about it, but the audit log is managed directly by coraza, and we can't configure it through Caddy (log rotation, compression...) And there is no option to pass a custom logger to coraza when creating the WAF instance |
Hmmm... how do you send your logs? Writing to file or stdout? If you write to a file, then you can just use filebeat to ship and rotate... |
Actually we use in VM : @fzipi
|
I've been using native audit log with filebeat since more than 6 years ago. Works like a charm in hundreds of servers. That was using modsecurity. But should be the same in this case. |
Native format logs are multiline, and rsyslog doesn't work well with multiline (it needs a regex to detect start of message) I managed to parse JSON Audit logs with Fluent to have a message that suits our needs in Elastic (it's mostly just a field mapping) :
Last thing I have to do now is to configure logrotate, maybe you have a example ? I read in an issue that I should use copytruncate. Anyway, thanks for the help 👍 |
I played a bit with audit logs options, to achieve exactly what we wanted. What we wanted : It appears that :
It's not easy to understand, but coraza is very modular :) |
Returning 403 is a defacto standard, but not the only choice. One thing that I do is to play with the return error from the WAF and then use a custom response. Disclaimer: _I didn't do this using Coraza + Caddy, but the conceptual idea is applicable IMHO. Example:
Result:
Hope this is useful. If you get it working, I think it is a good recipe for others and we could add it in our website 😄 |
Actually we only expose APIs with Caddy, for a mobile app. handle_errors is a good thing in Caddy, but it can't tell where the error comes from (ie, if we have several handlers which can throw a 403 error by example) So for now I'm happy with the default response from WAF, and auditing all transactions who matched a rule. |
All is working OK now :
|
WithErrorCallback() callback print error log messages with predefined Modsecurity format.
But this format lacks some informations to be ingested in our log sink (actually ElasticSearch) and be analyzed by developers :
If we could template the error log message with caddy replacer, we could add any relevant request information to log, and then add it in our log sink to analyze it.
@fzipi : what do you think about this ?
I can make a PR if needed, I already have a working branch on my fork
The text was updated successfully, but these errors were encountered: