-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Align "reference" field value in JSON transaction log with standard log. #3093
base: v3/master
Are you sure you want to change the base?
Conversation
Quality Gate passedIssues Measures |
Hi @asamuta, first of all: thank your for your contribution! Could you share with us some example, how can we reproduce this message in audit log? (Eg. share some details (eg. used rule set, special settings) and a |
Hi @airween, NGINX Additional rule that must be placed in REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
This is a simplified rule to demonstrate the issue. Payload - a big json (the example is attached). CURL: NOTE: Nginx in my case configured as a reverse proxy with upstream that targets a mock server that responds with simple valid JSON to all requests. |
LOGFY_ADD("reference", a.m_reference.c_str()); | ||
LOGFY_ADD("reference", utils::string::limitTo(200, a.m_reference).c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the semantic (which might be ok) but it also might break automated parsing tools. I think when we cut of data, the remaining stuff should still be parsable (e.g. cut of in a way that all the remaining data is valid and follow the expected format)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked the example to check the behavior on mod_security2.
Unfortunately I can't find any documentation about the expected behavior, but as I know this is not a bug, but a feature - I mean the audit.log contains the whole log entry.
In fact, the limitTo()
method is justified, because Nginx has a limit for the length of error.log line (NB: Apache has it too). But audit.log does not have any limit, so if we truncate the line in audit.log, we can lost relevant information.
In addition: I can imagine this PR can be a useful feature, but only with a configure option: if anyone wants to use this, then it can be optional in build time. Then we can be sure that user knows what he does.
Let me know how mod_security2 works.
Hi @MirkoDziadzka , @airween ,
How to interpret these numbers? How do these numbers help a SOC team? Is it worth storing tens of kilobytes? Ideally of course it should be possible to switch it on/off using "audit log parts" letters. But it will be a much more complicated task... I think the build time option is also a good point. Thanks for your efforts on this. |
Hi @asamuta, I developed this feature to pinpoint the exact location (within the request body or any other data) where the operator returned true. It was intended to highlight the relevant fragments related to the match, making visualization easier in the web console for specific use cases. The issue you've encountered seems to be a bug, although I haven't delved into the details. If it's not necessary, you can easily disable this feature with a build-time flag, or even at runtime if needed. Over the years, I've customized this for various consulting clients. If it's not being utilized, it might indeed be superfluous to retain this data. I understand your concern; even a few bytes can add up to significant costs over a billion requests. As per v2, I don't think this feature is available there. |
I agree that this feature might not be used. Unfortunately, (if I remember correctly), many regression tests are using the debug output of the variable origin. My concern with this PR: Assuming somebody is using this and parsing the line and it fails (e.g. simple python scripts would raise an exception) and some workflow is breaking. I'm not sure if this is a concern for the modec team, but long term ago I worked as a system admin and I would not like such a change. But not my decision. It might ok to just remove it. @asamuta regarding the format:
If we care to not break external parsers, we should probably split before "v" |
Hi All, If so, please point me to such "build-time flag" so that I can implement this based on that example. Also, it would be great if you could advise me the name of the new flag according to the naming convention used in the project. |
I can agree an optional, not mandatory modification.
As I know libmodsecurity3 does not have any kind of configure option which can be used to demonstrate the example. But mod_security2 has. You should check out the branch If you don't want to check the source tree and the build system's behavior, just see the For the name, I can imagine the The option name is not the best choice, so please help me to figure out the correct one. |
To everyone: what do you think about to make this feature optional? Do you think we can use the configure flag @asamuta could you prepare this patch with this suggestion? May be you should replace the name of the flag, but that's it, I guess. |
Transaction JSON log of "reference" is too verbose for some rules. There is a limit for "ref" field in "standard" log.
file: rule_message.cc
but there is no such limit in file: transaction.cc
With this fix JSON out will be truncated as standard log.
Before:
after the fix:
As long as there is no way to disable the "reference" field in JSON transaction log and the information it contains doesn't look useful in production logs please approve this change. I think the JSON log approach may be reworked later but meanwhile, we need a way to truncate it.