Fix WAF log parsing when there are multiple dicts in one line #9775
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Due to the way the WAF integration is currently designed, in case there was more than one dictionary in a single line (stored in the S3 bucket from which they have to be extracted), an error would occur when using
json.loads()
since that format is invalid:wazuh/wodles/aws/aws_s3.py
Lines 2079 to 2092 in af255be
This PR updates said part of the code so that, using raw_decoder, each line is divided into several dictionaries (if there are more than one per line). Therefore, now the following content would be valid, unlike what happened previously:
This change does not break previous functionality, it simply increases the flexibility of the WAF integration.
WAF log files
Part of the issue requested reviewing the WAF logs that we used for our developments. After doing so, I have been able to verify that they are not correct since they do not correspond to the information that said tool throws up. Here is an example of the logs we had:
To speed up the process, I have decided to add the logs that appear in the WAF documentation instead of generating our own:
Regards.